doskiran's Posts

Data Object - VirtualMachineConfigInfo(vim.vm.ConfigInfo) template - xsd:boolean - Flag indicating whether or not a virtual machine is a template. Sample code using VIJava API: -------------------... See more...
Data Object - VirtualMachineConfigInfo(vim.vm.ConfigInfo) template - xsd:boolean - Flag indicating whether or not a virtual machine is a template. Sample code using VIJava API: --------------------------------------- ManagedEntity[] meArr = new InventoryNavigator(si.getRootFolder()).searchManagedEntities("VirtualMachine"); for (ManagedEntity me : meArr) { VirtualMachine vm = (VirtualMachine) me; System.out.println("VM Name::" + vm.getName()+" ,IsTemplate(config.template)::"+vm.getConfig().isTemplate()); } Otherwise, Get All VirtualMachine objects along with the required properties using retrieveProperties() method of the PropertyCollector object.
Please refer to this doc - https://developer.vmware.com/docs/vsphere-automation/latest/appliance/api/appliance/access/ssh/put/ PowerCLI Client SDK Example # Module 'VMware.Sdk.vSphere.Applian... See more...
Please refer to this doc - https://developer.vmware.com/docs/vsphere-automation/latest/appliance/api/appliance/access/ssh/put/ PowerCLI Client SDK Example # Module 'VMware.Sdk.vSphere.Appliance.Access' $AccessSshSetRequestBody = Initialize-AccessSshSetRequestBody -Enabled $false Invoke-SetAccessSsh -AccessSshSetRequestBody $AccessSshSetRequestBody  
Missed "~" in the endpoint, ie,  POST - /rest/com/vmware/cis/tagging/tag-association?~action=list-attached-objects-on-tags POST (vSphere7.0U2) - /api/cis/tagging/tag-association?action=list-attache... See more...
Missed "~" in the endpoint, ie,  POST - /rest/com/vmware/cis/tagging/tag-association?~action=list-attached-objects-on-tags POST (vSphere7.0U2) - /api/cis/tagging/tag-association?action=list-attached-objects-on-tags Use the below sample to list the attached objects on the tag. import json import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) session = requests.Session() session.verify = False def get_vc_session(vc_ip, username, password): session.post('https://' + vc_ip + '/rest/com/vmware/cis/session', auth=(username, password)) return session def listAttachedObjectsOnTags(vc_ip, tag_id): payload = {"tag_ids": [tag_id]} payload = json.dumps(payload) headers = {'Content-type': 'application/json'} session1 = session.post( 'https://' + vc_ip + '/rest/com/vmware/cis/tagging/tag-association?~action=list-attached-objects-on-tags', data=payload, headers=headers) return session1.content if __name__ == '__main__': vc_ip = "10.xx.xx.xx" tag_id = "urn:vmomi:InventoryServiceTag:b4055c62-a0ed-44d9-babb-3e05a5416bcd:GLOBAL" get_vc_session(vc_ip, "<Username>", "<Password>") print(listAttachedObjectsOnTags(vc_ip, tag_id))  
Use TLS Configurator utility to enable or disable TLS Versions on ESXi Hosts. Starting with vSphere 6.7, the TLS Configurator utility is included in the product. You no longer download it separately... See more...
Use TLS Configurator utility to enable or disable TLS Versions on ESXi Hosts. Starting with vSphere 6.7, the TLS Configurator utility is included in the product. You no longer download it separately. Ref - https://kb.vmware.com/s/article/2147469 Ref- https://docs.vmware.com/en/VMware-vSphere/6.7/com.vmware.vsphere.security.doc/GUID-BDCE47DD-8AD2-4C98-94FF-7769D0BEE1C2.html *Note: Ensure that any products or services associated with the ESXi host can communicate using TLS 1.1 or TLS 1.2. For products that communicate only using TLS 1.0, connectivity is lost. - To disable TLS 1.2, and enable only TLS 1.1 on an individual host, run the following command. [ /usr/lib/vmware-TlsReconfigurator/EsxTlsReconfigurator ]# ./reconfigureEsx vCenterHost -h <ESXi_Host_Name> -u <vCenter_Administrative_User> -p TLSv1.1 or (on an standalone ESXi host) [ /usr/lib/vmware-TlsReconfigurator/EsxTlsReconfigurator ]# ./reconfigureEsx ESXiHost -h <ESXi_Host_Name> -u root -p TLSv1.1 - Once completed, the hosts will be flagged for reboot , reboot the ESXi host to complete the TLS protocol changes.  
From my understanding, not all vSphere REST APIs for the host get & post operations are available in the current releases. We may expect all REST APIs in the next vSphere major release. But for your... See more...
From my understanding, not all vSphere REST APIs for the host get & post operations are available in the current releases. We may expect all REST APIs in the next vSphere major release. But for your requirement use vSphere management SDK(SOAP-based APIs) to query host info. Below is the sample code written using VIJAVA API. public static void getHostInfo(String vcIPaddress, String userName, String password, String hostName) { try { ServiceInstance si = new ServiceInstance(new URL("https://" + vcIPaddress + "/sdk"), userName, password,true); HostSystem hs = (HostSystem) new InventoryNavigator(si.getRootFolder()).searchManagedEntity("HostSystem",hostName); // Host Version System.out.println("Host Version::" + hs.getSummary().getConfig().getProduct().getVersion()); // Host Health HealthSystemRuntime hostHealth = hs.getHealthStatusSystem().getRuntime(); System.out.println("HostHardwareStatusInfo::" + hostHealth.getHardwareStatusInfo()); System.out.println("HostSystemHealthInfo::" + hostHealth.getSystemHealthInfo()); // Weather or not Hyperthreading available System.out.println("Is Host Hyperthreading is available::" + hs.getConfig().getHyperThread().isAvailable()); // Host EVC info System.out.println( "EVC info::" + hs.getSummary().getCurrentEVCModeKey() + " , " + hs.getSummary().getMaxEVCModeKey()); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } }  
Command> shell.set --enabled True Unknown command: `shell.set' => There may be because of  "/storage/log" or audit.log or the root directory is full and cause such issues. Check these workarounds ... See more...
Command> shell.set --enabled True Unknown command: `shell.set' => There may be because of  "/storage/log" or audit.log or the root directory is full and cause such issues. Check these workarounds to enable bash shell - https://kb.vmware.com/s/article/2100508 - https://kb.vmware.com/s/article/2069041
List all hosts in a specific  cluster: ----------------------------------------- GET: https://{vc}/api/vcenter/host?clusters=<cluster_id>&connection_states=CONNECTED cluster_id = Identifier of the... See more...
List all hosts in a specific  cluster: ----------------------------------------- GET: https://{vc}/api/vcenter/host?clusters=<cluster_id>&connection_states=CONNECTED cluster_id = Identifier of the cluster Eg: https://{vc}/api/vcenter/host?clusters=domain-c8&connection_states=CONNECTED   How to get  cluster_id: ---------------------------- List Clusters - GET: https://{vc}/api/vcenter/cluster Res: { "drs_enabled": true, "cluster": "domain-c8", "name": "docker-cluster", "ha_enabled": false }  
Please check this sample code, Java Code:   CustomizationAdapterMapping cAdapterMapping = new CustomizationAdapterMapping(); CustomizationIPSettings cIPSettings = new CustomizationIPSettings(); ... See more...
Please check this sample code, Java Code:   CustomizationAdapterMapping cAdapterMapping = new CustomizationAdapterMapping(); CustomizationIPSettings cIPSettings = new CustomizationIPSettings(); CustomizationDhcpIpGenerator cDhcpIPGenerator = new CustomizationDhcpIpGenerator(); cIPSettings.setIp(cDhcpIPGenerator); cIPSettings.setNetBIOS(CustomizationNetBIOSMode.enableNetBIOSViaDhcp); cAdapterMapping.setAdapter(cIPSettings); CustomizationAdapterMapping[] cAdapterMappingArr = new CustomizationAdapterMapping[1]; cAdapterMappingArr[0] = cAdapterMapping;   Spec:   nicSettingMap = (vim.vm.customization.AdapterMapping) [ --> (vim.vm.customization.AdapterMapping) { --> macAddress = <unset>, --> adapter = (vim.vm.customization.IPSettings) { --> ip = (vim.vm.customization.DhcpIpGenerator) { --> }, --> subnetMask = <unset>, --> gateway = <unset>, --> ipV6Spec = (vim.vm.customization.IPSettings.IpV6AddressSpec) null, --> dnsServerList = <unset>, --> dnsDomain = <unset>, --> primaryWINS = <unset>, --> secondaryWINS = <unset>, --> netBIOS = <unset> --> } --> } --> ]            
NSX-T API to Attach DHCP Server to Logical Switch: ------------------------------------------------------------------ POST https://<nsx-mgr>/api/v1/logical-ports {      "logical_switch_id":<Id of... See more...
NSX-T API to Attach DHCP Server to Logical Switch: ------------------------------------------------------------------ POST https://<nsx-mgr>/api/v1/logical-ports {      "logical_switch_id":<Id of the Logical switch>,      "attachment":{          "attachment_type":"DHCP_SERVICE",          "id":<DHCP_SERVER_ID>       },      "admin_state":"UP" }
Try this code to get the ipV6 HostSystem object.. ManagedEntity[] hostManagedEntities = new InventoryNavigator(si.getRootFolder()) .searchManagedEntities("HostSystem"); for (ManagedEntity managedE... See more...
Try this code to get the ipV6 HostSystem object.. ManagedEntity[] hostManagedEntities = new InventoryNavigator(si.getRootFolder()) .searchManagedEntities("HostSystem"); for (ManagedEntity managedEntity : hostManagedEntities) {        HostSystem hs = (HostSystem) managedEntity;        HostVirtualNic[] hvNicArr = hs.getHostNetworkSystem().getNetworkInfo().getVnic();        for (HostVirtualNic hvNic : hvNicArr) {             HostVirtualNicSpec spec = hvNic.getSpec();             HostIpConfig hipConfig = spec.getIp();             HostIpConfigIpV6AddressConfiguration config = hipConfig.getIpV6Config();             if (config != null) {                  HostIpConfigIpV6Address[] ipV6AddressArr = config.getIpV6Address();                  for (HostIpConfigIpV6Address ipV6Address : ipV6AddressArr) {                       //Compare with respective ipV6Address and return HostSystem                      System.out.println(ipV6Address.getIpAddress());                 }            }       } }  
Importing OVF to deploy a new VM using VI Java API: Deploy OVF - https://code.vmware.com/samples/7622/deploy-ovf?h=Sample#code
Rest APIs: 1)  GET:  https://{vcenter}/api/vcenter/topology/nodes 2)  GET: https://{vcenter}/api/vcenter/topology/replication-status Web Service sample java code: Here is the sample code to get a... See more...
Rest APIs: 1)  GET:  https://{vcenter}/api/vcenter/topology/nodes 2)  GET: https://{vcenter}/api/vcenter/topology/replication-status Web Service sample java code: Here is the sample code to get all linked vCenters by using userAgent , here userAgent is the name of user agent or application. In my case I opened my linked VC atleast onetime with web client, so userAgent comparing with "web-client" in the code. Set<String> vcList = new HashSet<String>(); System.out.println(serviceInstance.getAboutInfo().getInstanceUuid()); SessionManager sessionMgr = serviceInstance.getSessionManager(); UserSession[] userSessions = sessionMgr.getSessionList(); for (UserSession userSession:userSessions) {       if (userSession.getUserName().contains("vsphere-webclient")) {           vcList.add(userSession.getIpAddress());       } }  
https://communities.vmware.com/t5/VMware-vCenter-Discussions/VCSA-Using-VAMI-API-to-start-stop-ssh-bash-etc/m-p/2835127/highlight/false#M42390 
With yavijava-6.0.05.jar we can still connect to VC7.0 +, Try this code, ServiceInstance si = new ServiceInstance(new URL("https://" + vcIPaddress + ":443/sdk"), userName, passwd, true); System.o... See more...
With yavijava-6.0.05.jar we can still connect to VC7.0 +, Try this code, ServiceInstance si = new ServiceInstance(new URL("https://" + vcIPaddress + ":443/sdk"), userName, passwd, true); System.out.println(si.getAboutInfo().getFullName()); // VMware vCenter Server 7.0.2 build-17694817 Also set below two VM arguments ,i.e, -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2 -DUSESSL=true My jars: ---------            
The way you have done is correct, i usually does this..                                                                                    LocalizedMethodFault fault = new LocalizedMethodFault()... See more...
The way you have done is correct, i usually does this..                                                                                    LocalizedMethodFault fault = new LocalizedMethodFault(); ManagedObjectNotFound monf = new ManagedObjectNotFound(); monf.setObj((ManagedObjectReference)vm); fault.setFault(monf); task.setTaskState(taskInfo.getTask(), TaskInfoState.ERROR, null, fault) 
Tags are actually stored and managed by the Inventory Service, use the Inventory service tagging API to retrieve the tags. For more information - https://communities.vmware.com/message/2409321#24... See more...
Tags are actually stored and managed by the Inventory Service, use the Inventory service tagging API to retrieve the tags. For more information - https://communities.vmware.com/message/2409321#2409321
Java program to Add existing disk to Powered on VM sample - https://code.vmware.com/samples/2122/hot-add-existing-disk?h=Java
Sample java program to extend existing VM harddisk with specified capacity using vSphere API. https://code.vmware.com/samples/1821/extend-vm-hard-disk?h=Sample  
There are multiple to do the Tag operations for VC inventory objects, 1) Use Inventory service Data providers , - VMware Knowledge Base Using Mob - https://vCenter_Server_FQDN/invsvc/mob1 ... See more...
There are multiple to do the Tag operations for VC inventory objects, 1) Use Inventory service Data providers , - VMware Knowledge Base Using Mob - https://vCenter_Server_FQDN/invsvc/mob1 2)  VMware-vSphere-Automation-SDK-Java-6.5.0 - Use package "com.vmware.cis.tagging" , which provide the Interfaces and classes to create, read, update, delete Category and Tag. 3)  Use vSphere REST APIs, - From VC -> Browse to vSphere REST APIs ->Select API-"cis"
VMA: ------- The vSphere Management Assistant 6.5 might fail to communicate with vCenter Server. This happens when vCenter Server instance is configured with TLSv1.1 or TLSv1.2 protocols. An er... See more...
VMA: ------- The vSphere Management Assistant 6.5 might fail to communicate with vCenter Server. This happens when vCenter Server instance is configured with TLSv1.1 or TLSv1.2 protocols. An error message similar to the following is displayed: Connect to ServerIP failed with ssl error 0x1. Workaround: Use an independent vSphere Command Line Interface 6.5. For more information, see the vSphere Command-Line Interface Concepts and Examplesand vSphere Command-Line Interface Reference. Java SDK: ------------- For java api to work , set "-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2" in program vm arguments.