public String getApiType() { return this.connection.getServiceContent().getAbout().getApiType(); }
public static void main(String[] args) throws Exception { ServiceInstance si = SampleUtil.createServiceInstance(); AboutInfo info = si.getAboutInfo(); System.out.println("=== vCenter Server Summary ==="); System.out.println("Name: " + info.getFullName()); System.out.println("UUID: " + info.getInstanceUuid()); System.out.println("Vendor: " + info.getVendor()); System.out.println("Version: " + info.getVersion()); System.out.println("OS Type: " + info.getOsType()); System.out.println("API Version: " + info.getApiVersion()); System.out.println("Cookie: " + si.getServerConnection().getSessionStr()); si.getServerConnection().logout(); }
/** * Create an instance of {@link AboutInfo } * */ public AboutInfo createAboutInfo() { return new AboutInfo(); }
System.out.println("Generating configuration files for '" + serviceInstance.getAboutInfo().getFullName() + "' using rrdRepository '" + rrdRepository + "'..."); buffer.append("Full name.......: " + serviceInstance.getAboutInfo().getFullName() + "\n"); buffer.append("API type........: " + serviceInstance.getAboutInfo().getApiType() + "\n"); buffer.append("API version.....: " + serviceInstance.getAboutInfo().getApiVersion() + "\n"); buffer.append("Product name....: " + serviceInstance.getAboutInfo().getLicenseProductName() + "\n"); buffer.append("Product version.: " + serviceInstance.getAboutInfo().getLicenseProductVersion() + "\n"); buffer.append("OS type.........: " + serviceInstance.getAboutInfo().getOsType() + "\n"); String[] arr = serviceInstance.getAboutInfo().getApiVersion().split("\\.");
/** * Returns the about info of the VMWare API */ private void getAbout(PrintWriter out) throws IOException { try { AboutInfo about = serviceInstance.getAboutInfo(); out.print(about.getFullName()); out.flush(); } catch (Exception ex) { LOG.error("An error occurred : " + ex.toString()); } }
/** * Return the major API version for this management server * * @return the major API version */ public int getMajorApiVersion() { if (m_serviceInstance != null) { String apiVersion = m_serviceInstance.getAboutInfo().getApiVersion(); String[] arr = apiVersion.split("\\."); if (arr.length > 1) { int apiMajorVersion = Integer.valueOf(arr[0]); if (apiMajorVersion < 4) { apiMajorVersion = 3; } return apiMajorVersion; } else { logger.error("Cannot parse vCenter API version '{}'", apiVersion); return 0; } } else { return 0; } }
public synchronized String getVCenterId() { if (vcenterUuid == null) { vcenterUuid = getServiceInstance().getAboutInfo().getInstanceUuid(); } return vcenterUuid; }
System.out.println("Generating configuration files for '" + serviceInstance.getAboutInfo().getFullName() + "' using rrdRepository '" + rrdRepository + "'..."); buffer.append("Full name.......: " + serviceInstance.getAboutInfo().getFullName() + "\n"); buffer.append("API type........: " + serviceInstance.getAboutInfo().getApiType() + "\n"); buffer.append("API version.....: " + serviceInstance.getAboutInfo().getApiVersion() + "\n"); buffer.append("Product name....: " + serviceInstance.getAboutInfo().getLicenseProductName() + "\n"); buffer.append("Product version.: " + serviceInstance.getAboutInfo().getLicenseProductVersion() + "\n"); buffer.append("OS type.........: " + serviceInstance.getAboutInfo().getOsType() + "\n"); String[] arr = serviceInstance.getAboutInfo().getApiVersion().split("\\.");
System.out.println("info---" + si.getAboutInfo().getFullName());
/** * Return the major API version for this management server * * @return the major API version */ public int getMajorApiVersion() { if (m_serviceInstance != null) { String apiVersion = m_serviceInstance.getAboutInfo().getApiVersion(); String[] arr = apiVersion.split("\\."); if (arr.length > 1) { int apiMajorVersion = Integer.valueOf(arr[0]); if (apiMajorVersion < 4) { apiMajorVersion = 3; } return apiMajorVersion; } else { logger.error("Cannot parse vCenter API version '{}'", apiVersion); return 0; } } else { return 0; } }
public static void main(String[] args) throws Exception { CommandLineParser clp = new CommandLineParser(constructOptions(), args); String urlStr = clp.get_option("url"); String username = clp.get_option("username"); String password = clp.get_option("password"); String dcname = clp.get_option("datacenter");; String hostname = clp.get_option("host"); String portGroupName = clp.get_option("portgroupname"); ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true); Folder rootFolder = si.getRootFolder(); HostSystem host = null; String apiType = si.getAboutInfo().getApiType(); if("HostAgent".equalsIgnoreCase(apiType) && dcname ==null) { dcname = "ha-datacenter"; } else if("VirtualCenter".equalsIgnoreCase(apiType) && ((dcname == null) || (hostname ==null))) { System.out.println("datacenter and host should be specified"); return; } Datacenter dc = (Datacenter) new InventoryNavigator(rootFolder).searchManagedEntity("Datacenter", dcname); host = (HostSystem) new InventoryNavigator(dc).searchManagedEntity("HostSystem", hostname); removeVirtualPortGroup(host, portGroupName); }
password, true); System.out.println("info---" + si.getAboutInfo().getFullName());
public ServiceInstance(URL url, String username, String password, boolean ignoreCert, String namespace) throws RemoteException, MalformedURLException { if(url == null || username==null) { throw new NullPointerException("None of url, username can be null."); } setMOR(SERVICE_INSTANCE_MOR); VimPortType vimService = new VimPortType(url.toString(), ignoreCert); vimService.getWsc().setVimNameSpace(namespace); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); vimService.getWsc().setSoapActionOnApiVersion(serviceContent.getAbout().getApiVersion()); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); //with new SOAP_ACTION setServerConnection(new ServerConnection(url, vimService, this)); UserSession userSession = getSessionManager().login(username, password, null); getServerConnection().setUserSession(userSession); }
public static void main(String[] args) throws Exception { CommandLineParser clp = new CommandLineParser(constructOptions(), args); String urlStr = clp.get_option("url"); String username = clp.get_option("username"); String password = clp.get_option("password"); String dcname = clp.get_option("datacenter");; String hostname = clp.get_option("host"); String portGroupName = clp.get_option("portgroupname"); ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true); Folder rootFolder = si.getRootFolder(); HostSystem host = null; String apiType = si.getAboutInfo().getApiType(); if("HostAgent".equalsIgnoreCase(apiType) && dcname ==null) { dcname = "ha-datacenter"; } else if("VirtualCenter".equalsIgnoreCase(apiType) && ((dcname == null) || (hostname ==null))) { System.out.println("datacenter and host should be specified"); return; } Datacenter dc = (Datacenter) new InventoryNavigator(rootFolder).searchManagedEntity("Datacenter", dcname); host = (HostSystem) new InventoryNavigator(dc).searchManagedEntity("HostSystem", hostname); removeVirtualNic(host, portGroupName); }
password, true); System.out.println("info---" + si.getAboutInfo().getFullName());
public ServiceInstance(URL url, String sessionStr, boolean ignoreCert, String namespace) throws RemoteException, MalformedURLException { if(url == null || sessionStr ==null) { throw new NullPointerException("None of url, session string can be null."); } setMOR(SERVICE_INSTANCE_MOR); VimPortType vimService = new VimPortType(url.toString(), ignoreCert); WSClient wsc = vimService.getWsc(); wsc.setCookie(sessionStr); wsc.setVimNameSpace(namespace); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); wsc.setSoapActionOnApiVersion(serviceContent.getAbout().getApiVersion()); setServerConnection(new ServerConnection(url, vimService, this)); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); //with new SOAP_ACTION UserSession userSession = (UserSession) getSessionManager().getCurrentProperty("currentSession"); getServerConnection().setUserSession(userSession); }
public static void main(String[] args) throws Exception { CommandLineParser clp = new CommandLineParser(constructOptions(), args); String urlStr = clp.get_option("url"); String username = clp.get_option("username"); String password = clp.get_option("password"); String dcname = clp.get_option("datacenter");; String hostname = clp.get_option("host"); String vswitchId = clp.get_option("vswitchid"); ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true); Folder rootFolder = si.getRootFolder(); HostSystem host = null; String apiType = si.getAboutInfo().getApiType(); if("HostAgent".equalsIgnoreCase(apiType) && dcname ==null) { dcname = "ha-datacenter"; } else if("VirtualCenter".equalsIgnoreCase(apiType) && ((dcname == null) || (hostname ==null))) { System.out.println("datacenter and host should be specified"); return; } Datacenter dc = (Datacenter) new InventoryNavigator(rootFolder).searchManagedEntity("Datacenter", dcname); host = (HostSystem) new InventoryNavigator(dc).searchManagedEntity("HostSystem", hostname); removeVirtualSwitch(host, vswitchId); }
System.out.println("info---" + si.getAboutInfo().getFullName());
vimService.getWsc().setSoapActionOnApiVersion(oldsi.getAboutInfo().getApiVersion());
public static void main(String[] args) throws Exception { CommandLineParser clp = new CommandLineParser(constructOptions(), args); String urlStr = clp.get_option("url"); String username = clp.get_option("username"); String password = clp.get_option("password"); String dcname = clp.get_option("datacenter");; String hostname = clp.get_option("host"); String portGroupName = clp.get_option("portgroupname"); ServiceInstance si = new ServiceInstance(new URL(urlStr), username, password, true); Folder rootFolder = si.getRootFolder(); HostSystem host = null; String apiType = si.getAboutInfo().getApiType(); if("HostAgent".equalsIgnoreCase(apiType) && dcname ==null) { dcname = "ha-datacenter"; } else if("VirtualCenter".equalsIgnoreCase(apiType) && ((dcname == null) || (hostname ==null))) { System.out.println("datacenter and host should be specified"); return; } Datacenter dc = (Datacenter) new InventoryNavigator(rootFolder).searchManagedEntity("Datacenter", dcname); host = (HostSystem) new InventoryNavigator(dc).searchManagedEntity("HostSystem", hostname); removeVirtualNic(host, portGroupName); }