private void prepareHost(HostMO hostMo, String privateTrafficLabel) throws Exception {
    // For ESX host, we need to enable host firewall to allow VNC access
    HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
    if (firewallMo != null) {
      if (hostMo.getHostType() == VmwareHostType.ESX) {
        firewallMo.enableRuleset("vncServer");
        firewallMo.refreshFirewall();
      }
    }

    // prepare at least one network on the vswitch to enable OVF importing
    String vSwitchName = privateTrafficLabel;
    String vlanId = null;
    String vlanToken;
    String[] tokens = privateTrafficLabel.split(",");
    if (tokens.length >= 2) {
      vSwitchName = tokens[0].trim();
      vlanToken = tokens[1].trim();
      if (!vlanToken.isEmpty()) {
        vlanId = vlanToken;
      }
    }
    s_logger.info(
        "Preparing network on host "
            + hostMo.getContext().toString()
            + " for "
            + privateTrafficLabel);
    // The management network is probably always going to be a physical network with vlans, so
    // assume BroadcastDomainType VLAN
    HypervisorHostHelper.prepareNetwork(
        vSwitchName,
        "cloud.private",
        hostMo,
        vlanId,
        null,
        null,
        180000,
        false,
        BroadcastDomainType.Vlan,
        null);
  }
  @Override
  public List<ManagedObjectReference> addHostToPodCluster(
      VmwareContext serviceContext, long dcId, Long podId, Long clusterId, String hostInventoryPath)
      throws Exception {
    ManagedObjectReference mor = serviceContext.getHostMorByPath(hostInventoryPath);
    if (mor != null) {
      List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();

      if (mor.getType().equals("ComputeResource")) {
        ManagedObjectReference[] hosts =
            (ManagedObjectReference[])
                serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
        assert (hosts != null);

        // For ESX host, we need to enable host firewall to allow VNC access
        HostMO hostMo = new HostMO(serviceContext, hosts[0]);
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if (firewallMo != null) {
          firewallMo.enableRuleset("vncServer");
          firewallMo.refreshFirewall();
        }

        // prepare at least one network on the vswitch to enable OVF importing
        String managementPortGroupName =
            hostMo.getPortGroupNameByNicType(HostVirtualNicType.management);
        assert (managementPortGroupName != null);
        HostPortGroupSpec spec = hostMo.getPortGroupSpec(managementPortGroupName);
        Integer vlanId = null;
        if (spec.getVlanId() != 0) {
          vlanId = spec.getVlanId();
        }

        HypervisorHostHelper.preparePrivateNetwork(
            _privateNetworkVSwitchName, hostMo, vlanId, 180000);
        returnedHostList.add(hosts[0]);
        return returnedHostList;
      } else if (mor.getType().equals("ClusterComputeResource")) {
        ManagedObjectReference[] hosts =
            (ManagedObjectReference[])
                serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
        assert (hosts != null);

        if (hosts.length > _maxHostsPerCluster) {
          String msg =
              "vCenter cluster size is too big (current configured cluster size: "
                  + _maxHostsPerCluster
                  + ")";
          s_logger.error(msg);
          throw new DiscoveredWithErrorException(msg);
        }

        for (ManagedObjectReference morHost : hosts) {
          // For ESX host, we need to enable host firewall to allow VNC access
          HostMO hostMo = new HostMO(serviceContext, morHost);
          HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
          if (firewallMo != null) {
            firewallMo.enableRuleset("vncServer");
            firewallMo.refreshFirewall();
          }

          String managementPortGroupName =
              hostMo.getPortGroupNameByNicType(HostVirtualNicType.management);
          assert (managementPortGroupName != null);
          HostPortGroupSpec spec = hostMo.getPortGroupSpec(managementPortGroupName);
          Integer vlanId = null;
          if (spec.getVlanId() != 0) {
            vlanId = spec.getVlanId();
          }

          // prepare at least one network on the vswitch to enable OVF importing
          HypervisorHostHelper.preparePrivateNetwork(
              _privateNetworkVSwitchName, hostMo, vlanId, 180000);
          returnedHostList.add(morHost);
        }
        return returnedHostList;
      } else if (mor.getType().equals("HostSystem")) {
        // For ESX host, we need to enable host firewall to allow VNC access
        HostMO hostMo = new HostMO(serviceContext, mor);
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if (firewallMo != null) {
          firewallMo.enableRuleset("vncServer");
          firewallMo.refreshFirewall();
        }

        String managementPortGroupName =
            hostMo.getPortGroupNameByNicType(HostVirtualNicType.management);
        assert (managementPortGroupName != null);
        HostPortGroupSpec spec = hostMo.getPortGroupSpec(managementPortGroupName);
        Integer vlanId = null;
        if (spec.getVlanId() != 0) {
          vlanId = spec.getVlanId();
        }

        // prepare at least one network on the vswitch to enable OVF importing
        HypervisorHostHelper.preparePrivateNetwork(
            _privateNetworkVSwitchName, hostMo, vlanId, 180000);
        returnedHostList.add(mor);
        return returnedHostList;
      } else {
        s_logger.error(
            "Unsupport host type "
                + mor.getType()
                + ":"
                + mor.get_value()
                + " from inventory path: "
                + hostInventoryPath);
        return null;
      }
    }

    s_logger.error("Unable to find host from inventory path: " + hostInventoryPath);
    return null;
  }