Java 类com.vmware.vim25.NetworkSummary 实例源码

项目:oscm    文件:NetworkManager.java   
public static String getNetworkName(VMwareClient vmw,
        ManagedObjectReference vmwInstance, int numNic) throws Exception {
    logger.debug("");

    List<ManagedObjectReference> networkList = (List<ManagedObjectReference>) vmw
            .getServiceUtil().getDynamicProperty(vmwInstance, "network");

    String name = null;
    if (networkList != null && networkList.size() >= numNic) {
        name = (String) vmw.getServiceUtil()
                .getDynamicProperty(networkList.get(numNic - 1), "name");
        NetworkSummary summary = (NetworkSummary) vmw.getServiceUtil()
                .getDynamicProperty(networkList.get(numNic - 1), "summary");

        logger.debug(
                "name: " + name + " ipPoolId: " + summary.getIpPoolName()
                        + " ipPoolName: " + summary.getName());
    }

    if (name == null) {
        throw new Exception(
                "Failed to retrieve network name from template.");
    }
    return name;
}
项目:development    文件:NetworkManager.java   
public static String getNetworkName(VMwareClient vmw,
        ManagedObjectReference vmwInstance, int numNic) throws Exception {
    logger.debug("");

    List<ManagedObjectReference> networkList = (List<ManagedObjectReference>) vmw
            .getServiceUtil().getDynamicProperty(vmwInstance, "network");

    String name = null;
    if (networkList != null && networkList.size() >= numNic) {
        name = (String) vmw.getServiceUtil()
                .getDynamicProperty(networkList.get(numNic - 1), "name");
        NetworkSummary summary = (NetworkSummary) vmw.getServiceUtil()
                .getDynamicProperty(networkList.get(numNic - 1), "summary");

        logger.debug(
                "name: " + name + " ipPoolId: " + summary.getIpPoolName()
                        + " ipPoolName: " + summary.getName());
    }

    if (name == null) {
        throw new Exception(
                "Failed to retrieve network name from template.");
    }
    return name;
}
项目:vijava    文件:VmNicOp.java   
static boolean doesNetworkNameExist(VirtualMachine vm, 
    String netName) throws Exception 
{
  VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
  EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser();
  ManagedObjectReference hmor = vmRuntimeInfo.getHost();

  HostSystem host = new HostSystem(
      vm.getServerConnection(), hmor);
  ConfigTarget cfg = envBrowser.queryConfigTarget(host);
  VirtualMachineNetworkInfo[] nets = cfg.getNetwork();
  for (int i = 0; nets!=null && i < nets.length; i++) 
  {
    NetworkSummary netSummary = nets[i].getNetwork();
    if (netSummary.isAccessible() && 
        netSummary.getName().equalsIgnoreCase(netName)) 
    {
      return true;
    }
  }
  return false;
}
项目:vijava    文件:VirtualMachineDeviceManager.java   
private static NetworkSummary getHostNetworkSummaryByName(String networkName, VirtualMachineNetworkInfo[] hostNetworkList) 
{
  NetworkSummary result = null;
  boolean isNetworkExistingOnHost = false;

   // Check each of the provided network names against host networks to see if it exists on host
  for (VirtualMachineNetworkInfo netInfo : hostNetworkList) 
  {
    if (networkName.equals(netInfo.name)) 
    {
      isNetworkExistingOnHost = true;

      if (netInfo.network.accessible) 
      {
        result = netInfo.network;
        break;
      }
      else
      {
        throw new RuntimeException("Network: " + networkName + " is not accessible."); 
      }
    }
  }
  if (!isNetworkExistingOnHost) 
  {
    throw new RuntimeException("Network: " + networkName + " does not exist on host network."); 
  }
  return result;
}
项目:photon-model    文件:NetworkOverlay.java   
public NetworkSummary getSummary() {
    return (NetworkSummary) getOrDefault(VimPath.net_summary, null);
}