Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

I am not seeing it, where am I going wrong with the code?

$
0
0

I am working on a workflow to reconfigure a vCenter alarm to add a SNMP receiver, port and community.  Actually I need this in two part, first to check to see if it is already configured and compare to what is presented to make sure the config is correct or to fix it.  First step, getting the alarm to update.  I was using Onyx to help with the code but I keep getting this error

 

 

[2015-04-07 21:14:02.009] [I] TypeError: Cannot find function reconfigureAlarm in object DynamicWrapper (Instance) : [VcFolder]-[class com.vmware.vmo.plugin.vi4.model.VimFolder] -- VALUE : Folder<group-d1>. (Workflow:Copy of Alarms - Host Connection and Power / Scriptable task (item1)#57)

 

 

This workflow scripting task takes this variable  vc = VC:SDKConnection

 

Where in the world am I going wrong?

 

//System.log(vc.alarmManager.vimType)
var alarm = vc.alarmManager.getAlarm()
for each ( var a in alarm ){
System.log(a.info.name)
if ( a.info.name == "Host connection and power state"){
var alarmEntity = a.info.entity
var alarmType = a.vimType
System.log("Found Alarm Entity: "+alarmEntity)
break;;
}
}
var hostalarm = vc.alarmManager.getAlarm(alarmEntity)
//System.log(hostalarm)
//System.log(alarmEntity)

// ------- ReconfigureAlarm -------
var managedObject = alarmEntity
var spec = new VcAlarmInfo();
spec.name = "Host connection and power state";
spec.systemName = "alarm.HostConnectionStateAlarm";
spec.description = "Default alarm to monitor host connection and power state";
spec.enabled = true;
spec.expression = new VcAndAlarmExpression();
spec.expression.expression = System.getModule("com.vmware.onyx").array(VcStateAlarmExpression, 2);
spec.expression.expression[0] = new VcStateAlarmExpression();
spec.expression.expression[0].operator = VcStateAlarmOperator.isEqual;
spec.expression.expression[0].type = "HostSystem";
spec.expression.expression[0].statePath = "runtime.connectionState";
spec.expression.expression[0].red = "notResponding";
spec.expression.expression[1] = new VcStateAlarmExpression();
spec.expression.expression[1].operator = VcStateAlarmOperator.isUnequal;
spec.expression.expression[1].type = "HostSystem";
spec.expression.expression[1].statePath = "runtime.powerState";
spec.expression.expression[1].red = "standBy";
spec.action = new VcGroupAlarmAction();
spec.action.action = System.getModule("com.vmware.onyx").array(VcAlarmTriggeringAction, 1);
spec.action.action[0] = new VcAlarmTriggeringAction();
spec.action.action[0].action = new VcSendSNMPAction();
spec.action.action[0].transitionSpecs = System.getModule("com.vmware.onyx").array(VcAlarmTriggeringActionTransitionSpec, 1);
spec.action.action[0].transitionSpecs[0] = new VcAlarmTriggeringActionTransitionSpec();
spec.action.action[0].transitionSpecs[0].startState = VcManagedEntityStatus.yellow;
spec.action.action[0].transitionSpecs[0].finalState = VcManagedEntityStatus.red;
spec.action.action[0].transitionSpecs[0].repeats = false;
//spec.action.action[0].green2yellow = false;
//spec.action.action[0].yellow2red = false;
//spec.action.action[0].red2yellow = false;
//spec.action.action[0].yellow2green = false;
spec.setting = new VcAlarmSetting();
spec.setting.toleranceRange = 0;
spec.setting.reportingFrequency = 300;

 

spec.key = "alarm-1";
spec.alarm = Server.findForType("VC:HostSystem", managedObject.vimHost.id + "/alarm-1");;
spec.entity = Server.findForType("VC:HostFolder", managedObject.vimHost.id + "/group-d1");;
//spec.lastModifiedTime = new Date("2013-09-30T16:38:54.59Z");
//spec.lastModifiedUser = "";
spec.creationEventId = 0;

task = managedObject.reconfigureAlarm(spec);  // Alarm

 

 

 

Thanks

 

Steve


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>