Java vsphere Client's third party package via VMware to manipulate virtual machines via host or data center

Source: Internet
Author: User
Tags stringbuffer

Operating Windows,linux and other virtual machines can be ssh,wmi to operate the shutdown, restart. You can also add a virtual machine to the host, data center by first. Then through the host, data center to manipulate. This is the same thing that can be done with VMware vsphere Client management tools. The package used

Packages used: Vijava.jar

 public static void Main (string[] args) {try {String ip= ' 192.168.10.60 ';  
	        	Clientsesion session = new Clientsesion ("Address", "username", "password");
	    		StringBuffer protocol = new StringBuffer ("https");
	    		Protocol.append ("://");
	    		Protocol.append (IP);
	    		Protocol.append (":");
	    		Protocol.append (443);
	    		Protocol.append ("/");
	    		Protocol.append ("SDK");
	            String urlstr = protocol.tostring ();  
	            URL url = new URL (urlstr);  
	  
	            Serviceinstance si = new serviceinstance (URL, "root", "gzyl@38921561", true);  
	            Folder RootFolder = Si.getrootfolder (); managedentity mes = new Inventorynavigator (rootfolder). Searchmanagedentity ("Virtualmachine", "Windows 2008 R2_Test  
	            & "225");  
	                if (mes!= null) {Virtualmachine virtualmachine = (virtualmachine) mes;  
	       System.out.println ("Virtualmachine Name:" +virtualmachine.getname ());         Virtual machine reload//Virtualmachine.reload ();  
	                Virtual Organization Machine virtualmachine.shutdownguest ();  
	            Virtual machine standby//virtualmachine.standbyguest ();  
	            }else{si.getserverconnection (). Logout ();  
	        }}catch (Exception e) {e.printstacktrace ();  
 }  
	  
	  
	        }


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.