本文整理匯總了Java中com.vmware.vim25.ClusterRecommendation類的典型用法代碼示例。如果您正苦於以下問題:Java ClusterRecommendation類的具體用法?Java ClusterRecommendation怎麽用?Java ClusterRecommendation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ClusterRecommendation類屬於com.vmware.vim25包,在下文中一共展示了ClusterRecommendation類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: recommendationToString
import com.vmware.vim25.ClusterRecommendation; //導入依賴的package包/類
static String recommendationToString(
ClusterRecommendation rec)
{
StringBuffer sb = new StringBuffer();
sb.append("\nRating:" + rec.getRating());
sb.append("\nReasonText:" + rec.getReasonText());
sb.append("\nKey:" + rec.getKey());
sb.append("\nTarget:" + rec.getTarget());
sb.append("\nTime:" + new Date(
rec.getTime().getTimeInMillis()));
return sb.toString();
}
示例2: main
import com.vmware.vim25.ClusterRecommendation; //導入依賴的package包/類
public static void main(String[] args) throws Exception
{
if(args.length!=3)
{
System.out.println("Usage: java DrsApp " +
"<url> <username> <password>");
System.exit(0);
}
ServiceInstance si = new ServiceInstance(
new URL(args[0]), args[1], args[2], true);
Folder root = si.getRootFolder();
ManagedEntity[] mes = new InventoryNavigator(
root).searchManagedEntities("ClusterComputeResource");
if(mes==null || mes.length == 0)
{
System.out.println("There is no DRS cluster. Exiting.");
si.getServerConnection().logout();
return;
}
ClusterComputeResource ccr =
((ClusterComputeResource)mes[0]);
EmailMessenger em = new EmailMessenger(
"mailhost1.vmware.com", "username", "password");
for(;;)
{
StringBuffer sb = new StringBuffer();
ClusterRecommendation[] recs = ccr.getRecommendation();
if(recs!=null)
{
for(int i=0; i< recs.length; i++)
{
sb.append("\n\nRecommendation #" + (i+1));
sb.append(recommendationToString(recs[i]));
sb.append("\nPlease click the following URL " +
"and enter " + recs[i].getKey()
+ " as key to apply this recommendation:");
sb.append(createMobUrl(args[0], ccr)
+ "&method=applyRecommendation");
sb.append("\nThe time window for applying " +
"recommendations is 5 mins. Please act ASAP!");
}
// the receiver's email address
String recvEmail = "[email protected]***.com";
System.out.println("Sending DRS recommendation email to:"
+ recvEmail);
em.sendEmailTo(recvEmail, "DRS Messenger -- "
+ recs.length + " recommendation(s)", sb.toString());
}
Thread.sleep(1*60*1000); //wait for 1 minute
}
}