// get the parent vc resource pool of the node
public static VcResourcePool getTargetRp(String clusterName,
String groupName, NodeEntity node) {
String clusterRpName = ConfigInfo.getSerengetiUUID() + "-" + clusterName;
VcResourcePoolEntity rpEntity = node.getVcRp();
String vcRPName = "";
try {
VcCluster cluster =
VcResourceUtils.findVcCluster(rpEntity.getVcCluster());
if (!cluster.getConfig().getDRSEnabled()) {
logger.debug("DRS disabled for cluster " + rpEntity.getVcCluster()
+ ", put VM under cluster directly.");
return cluster.getRootRP();
}
if (CommonUtil.isBlank(rpEntity.getVcResourcePool())) {
vcRPName = clusterRpName + "/" + groupName;
} else {
vcRPName =
rpEntity.getVcResourcePool() + "/" + clusterRpName + "/"
+ groupName;
}
VcResourcePool rp =
VcResourceUtils.findRPInVCCluster(rpEntity.getVcCluster(),
vcRPName);
if (rp == null) {
throw ClusteringServiceException.TARGET_VC_RP_NOT_FOUND(
rpEntity.getVcCluster(), vcRPName);
}
return rp;
} catch (Exception e) {
logger.error("Failed to get VC resource pool " + vcRPName
+ " in vc cluster " + rpEntity.getVcCluster(), e);
throw ClusteringServiceException.TARGET_VC_RP_NOT_FOUND(
rpEntity.getVcCluster(), vcRPName);
}
}