コード例 #1
0
  private void populateVMs(VirtualNetworkInfo vn, VmwareVirtualNetworkInfo vmwareVN) {
    SandeshObjectList<VirtualMachineInfo> vMachines = vn.getVMachines();

    if (vMachines == null) {
      return;
    }
    SortedMap<String, VmwareVirtualMachineInfo> map = vmwareVN.getVmInfo();

    if (map == null) {
      return;
    }
    for (Map.Entry<String, VmwareVirtualMachineInfo> entry : map.entrySet()) {
      VmwareVirtualMachineInfo vmwareVM = entry.getValue();

      if (!vrouter.getEsxiHost().trim().equals(vmwareVM.getHostName().trim())) {
        continue;
      }

      VirtualMachineInfo vm = new VirtualMachineInfo();
      vm.setName(vmwareVM.getName());
      vm.setIpAddr(vmwareVM.getIpAddress());
      vm.setMacAddr(vmwareVM.getMacAddress());
      vm.setEsxiHost(vmwareVM.getHostName());
      vm.setPowerState(vmwareVM.getPowerState().name());
      vm.setNetwork(vn.getName());

      vMachines.add(vm);
    }
  }
コード例 #2
0
  private void populateVNetworks(SandeshObjectList<VirtualNetworkInfo> vNetworks) {
    SortedMap<String, VmwareVirtualNetworkInfo> entries =
        VCenterMonitor.getVcenterDB().getPrevVmwareVNInfos();

    if (entries == null) {
      return;
    }

    for (Map.Entry<String, VmwareVirtualNetworkInfo> entry : entries.entrySet()) {
      VmwareVirtualNetworkInfo vmwareVN = entry.getValue();
      VirtualNetworkInfo vn = new VirtualNetworkInfo();
      populateVMs(vn, vmwareVN);
      if (vn.getVMachines().size() > 0) {
        vn.setName(vmwareVN.getName());
        vNetworks.add(vn);
      }
    }
  }