@Override public AboutInfo getVersion() { login(); AboutInfo ai = serviceInstance.getAboutInfo(); return ai; }
/** * 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; } }
/** * 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; }
private void validateDVPortGroupForVNicConnection(DistributedVirtualPortgroupInfo dvPortgroupInfo) { if (dvPortgroupInfo.uplinkPortgroup) { throw new RuntimeException("The vDS portgroup's uplinkPortgroup should not be null"); } DistributedVirtualPortgroupPortgroupType portgroupType = DistributedVirtualPortgroupPortgroupType.valueOf(dvPortgroupInfo.portgroupType); String prodLineId = vm.getServerConnection().getServiceInstance().getAboutInfo().getProductLineId(); // standalone host cannot do early or late binding if (prodLineId.indexOf("ESX")!=-1 && (portgroupType == DistributedVirtualPortgroupPortgroupType.earlyBinding || portgroupType == DistributedVirtualPortgroupPortgroupType.lateBinding)) { throw new RuntimeException("ESX does not support early or late binding!"); } }
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(); }
password, true); System.out.println("info---" + si.getAboutInfo().getFullName());
password, true); System.out.println("info---" + si.getAboutInfo().getFullName());
private void login() { HashMap<String, String> configMap = acqConifMap(); String vcsaHost = configMap.get(VcsaItemEnum.VCSA_HOST.getItemKey()); String vcsaUser = configMap.get(VcsaItemEnum.VCSA_USER.getItemKey()); String vcsaPasswd = configMap.get(VcsaItemEnum.VCSA_PASSWD.getItemKey()); if (serviceInstance != null) return; try { ClientSesion session = new ClientSesion(vcsaHost, vcsaUser, vcsaPasswd); URL url = new URL("https", session.getHost(), "/sdk"); ServiceInstance si = new ServiceInstance(url, session.getUsername(), session.getPassword(), true); //rootFolder = si.getRootFolder(); serviceInstance = si; //VCenter vc = new VCenter(); AboutInfo ai = si.getAboutInfo(); //System.out.println("名称" + ai.getFullName()); //System.out.println("版本:" + ai.getVersion()); //System.out.println(ai.apiType); //si.currentTime(); } catch (Exception e) { e.printStackTrace(); logger.error("VCSA Sever : {} 登陆失败 !", vcsaHost); serviceInstance = null; } }
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); }
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); }
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); }
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); }
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); }
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); }
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"); 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); addVirtualSwitchPortGroup(host, vswitchId, portGroupName); }
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"); 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); addVirtualSwitchPortGroup(host, vswitchId, portGroupName); }
AboutInfo ai = rootEntity.getServerConnection().getServiceInstance().getAboutInfo();
vimService.getWsc().setSoapActionOnApiVersion(oldsi.getAboutInfo().getApiVersion());