当前位置: 首页>>代码示例>>Java>>正文


Java ServiceInstance.getAlarmManager方法代码示例

本文整理汇总了Java中com.vmware.vim25.mo.ServiceInstance.getAlarmManager方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceInstance.getAlarmManager方法的具体用法?Java ServiceInstance.getAlarmManager怎么用?Java ServiceInstance.getAlarmManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vmware.vim25.mo.ServiceInstance的用法示例。


在下文中一共展示了ServiceInstance.getAlarmManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
  if(args.length != 3)
  {
    System.out.println("Usage: java PrintAlarmManager " 
      + "<url> <username> <password>");
    return;
  }

  ServiceInstance si = new ServiceInstance(
    new URL(args[0]), args[1], args[2], true);
   
  AlarmManager alarmMgr = si.getAlarmManager();

  System.out.println("Alarm expressions:");
  AlarmExpression[] defaultExps = alarmMgr.getDefaultExpression();
  printAlarmExpressions(defaultExps);

  System.out.println("\n\nAlarm descriptions:");
  AlarmDescription ad = alarmMgr.getDescription();
  printAlarmDescription(ad);
  
  si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:25,代码来源:PrintAlarmManager.java

示例2: main

import com.vmware.vim25.mo.ServiceInstance; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception 
{
  if(args.length != 4)
  {
    System.out.println("Usage: java CreateVmAlarm " 
        + "<url> <username> <password> <vmname>");
    return;
  }

  ServiceInstance si = new ServiceInstance(
      new URL(args[0]), args[1], args[2], true);

  String vmname = args[3];
  InventoryNavigator inv = new InventoryNavigator(
      si.getRootFolder());
  VirtualMachine vm = (VirtualMachine)inv.searchManagedEntity(
          "VirtualMachine", vmname);
  if(vm==null)
  {
    System.out.println("Cannot find the VM " + vmname 
      + "\nExisting...");
    si.getServerConnection().logout();
    return;
  }
  
  AlarmManager alarmMgr = si.getAlarmManager();
  
  AlarmSpec spec = new AlarmSpec();
  
  StateAlarmExpression expression = 
    createStateAlarmExpression();
  AlarmAction emailAction = createAlarmTriggerAction(
      createEmailAction());
  AlarmAction methodAction = createAlarmTriggerAction(
      createPowerOnAction());
  GroupAlarmAction gaa = new GroupAlarmAction();

  gaa.setAction(new AlarmAction[]{emailAction, methodAction});
  spec.setAction(gaa);
  spec.setExpression(expression);
  spec.setName("VmPowerStateAlarm");
  spec.setDescription("Monitor VM state and send email " +
  		"and power it on if VM powers off");
  spec.setEnabled(true);    
  
  AlarmSetting as = new AlarmSetting();
  as.setReportingFrequency(0); //as often as possible
  as.setToleranceRange(0);
  
  spec.setSetting(as);
  
  alarmMgr.createAlarm(vm, spec);
  
  si.getServerConnection().logout();
}
 
开发者ID:Juniper,项目名称:vijava,代码行数:56,代码来源:CreateVmAlarm.java


注:本文中的com.vmware.vim25.mo.ServiceInstance.getAlarmManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。