360 likes | 437 Views
All About Events, Alarms, and Tasks TEXIBP1004 Balaji Parimi, VMware Inc. This session may contain product features that are currently under development.
E N D
All About Events, Alarms, and Tasks TEXIBP1004 Balaji Parimi, VMware Inc.
This session may contain product features that are currently under development. This session/overview of the new technology represents no commitment from VMware to deliver these features in any generally available product. Features are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind. Technical feasibility and market demand will affect final delivery. Pricing and packaging for any new technologies or features discussed or presented have not been determined. Disclaimer “These features are representative of feature areas under development. Feature commitments are subject to change, and must not be included in contracts, purchase orders, or sales agreements of any kind. Technical feasibility and market demand will affect final delivery.”
Facebook Search for VMware Partner Network TwitterSearch for VMware_Partners http://blogs.vmware.com/powerofpartnership/ Linkedin Search for VMware Partner Network Follow Us t Join the conversationGet the latest scoopBe a part of the network Subscribe to RSS Follow this event LIVE! #VMwarePEX2010 Help us help you! Please fill out the survey at the end of the course.
Introduction • This session assumes that the audience are familiar with vSphere Web Services SDK and its usage.
About the Speaker • Balaji Parimi, Sr. MTS, VMware Inc. • Current role and responsibilities • VMware engineering consultant to the partners, focusing on creating solutions based on VMware’s vSphere platform. • Train partner engineering teams on using the vSphere APIs. • Review partner’s solution architecture. • Background • Have a master’s degree in Computer Science and a master’s degree in Software Engineering. • Have been working in the industry since 1998.
Agenda • Events • Custom events • Retrieving information about events • Event notification using EventHistoryCollector • Tasks • Custom tasks • Retrieving information about tasks • Alarms • Creating an alarm • Q & A
Events • Events convey information about changes in the state of managed entities. • E.g.: Powering on / off a VM, adding a new ESX / ESXi system to a vCenter Server, migrating a VM (VMotion) from one host to another etc. • Event is a data object with many subtypes that define specific events that the system generates. • E.g.: VmPoweredOnEvent, VmCreatedEvent etc. • vCenter Server stores the Events information for all its managed ESX / ESXi systems in its database. • Events data is purged from the vCenter Server database to keep the size of the database in check.
Custom Events • vSphere SDK Client applications can inject custom events that show up in vSphere client • Two ways to do it: • Using logUserEvent API • Allows the client applications to specify only a logging message against the entity (must be a rootFolder, Datacenter, VM, HostSystem, or a ComputeResource) for which the event is being logged. • Using postEvent API • Allows the client applications to create an Event object and post that specific Event. This Event can be associated with a specific Task as well.
User Defined Event with LogUserEvent API 89% of all virtualized applications in the world run on VMware. tn, December 2008
EventManager • EventManager is the service interface that provides necessary properties and methods for event management. • Find the latest event that happened • Query events (can filter the query using EventFilterSpec) • Log user defined event • Post a specific event • Create event collectors • Find the maximum number of event collectors that can exist simultaneously per client session
EventManager Managed Object 89% of all virtualized applications in the world run on VMware. tner, December 2008
Code Snippet Using logUserEvent API • public voidusingLogUserEvent(String myEventMsg) { • vimPort.logUserEvent(eventMgr, moRef, myEventMsg); • }
Code Snippet Using postEvent API • public voidusingPostEvent(String myEventMsg) { • ExtendedEevnt myEvent = new ExtendedEvent(); • myEvent.setChainId(0); //Use eventChainId of TaskInfo, if it is passed • myEvent.setKey(0);//Set this to 0 and vCenter will fill the appropriate values • myEvent.setCreatedTime(new GregorianCalendar()); • myEvent.setFullFormattedMessage(myEventMsg); • myEvent.setUserName(“ME”); • myEvent.setMessage(myEventMsg); • myEvent.setEventTypeId(“com.xxx.yyy.MyEvent”); • myEvent.setManagedObject(moRef); • vimPort.postEvent(eventMgr, myEvent, null); • }
Retrieving Information about Events • EventManager managed object’s ‘latestEvent’ will provide information about the latest event that happened in the vCenter Server. • vSphere SDK client programs can retrieve information about any event from the vCenter Server using EventHistoryCollector. • The events information retrieval can be filtered based on a specific managed entity, window of time, user name, event type etc. using EventFilterSpec. • The EventHistoryCollector can also be used to keep track of the latest event filtered by the EventFilterSpec. • EventHistoryCollector is session specific.
EventHistoryCollector • Create EventHistoryCollector with the appropriate EventFilterSpec to gather information about the events of interest. • The ‘latestPage’ property of the EventHistoryCollector contains the most recent (1000 by default) Event data objects ordered by time stamp. • The ‘latestPage’ property is updated with the latest Event data objects that meet the filter criteria. • The oldest Event data object is removed from the ‘latestPage’ to make room for the latest one. • The size of the ‘latestPage’ can be modified.
Event Notification using EventHistoryCollector • Every new Event generation results in ‘latestPage’ property of the EventHistoryCollector change. • Using PropertyCollector and waitForUpdates, the client programs can monitor for changes to this property and send appropriate notifications. • The same approach can be used to trigger any other workflows or take some action etc.
Tasks • Tasks are asynchronous operations performed on managed entities. • Tasks are of two types: active and scheduled • Active task is the task in the process of performing some action. • All the APIs that end with “_Task” return active Task. E.g.: powerOnVM_Task. • Scheduled task is the action that a user wants to perform on a managed entity at a specified time. • A scheduled task becomes an active task, as soon as its scheduled action is triggered. • Task object has ‘info’ (of type TaskInfo) property. The ‘progress’ property of TaskInfo object conveys the task progress in terms of percentage.
Tasks • Tasks have four states: error, queued, running and success. • Tasks are queued when there are too many tasks for threads to handle. • The running state of queued tasks is marked as running. • Whenever a thread is freed from its current task, it is assigned a queued task to run.
Tasks • Task can be cancelled using cancelTask API. • May only be cancelled if it is cancellable. • It has to be in either running or queued state. • Multiple cancel requests are treated as a single cancellation request. • After successful cancellation, the runtime state is set to error and the error state is set to RequestCanceled. • Cancel operation is asynchronous and it may return before the task is canceled. • Canceling a scheduled task cancels only the current run of the scheduled task. It does not cancel the subsequent runs. • Use removeScheduledTask API to remove scheduled tasks.
Custom Tasks • vSphere SDK Client applications can inject custom tasks that show up in vSphere client using ‘createTask’ API • Requires the client application to specify the managed object associated with the Task, the type of task and whether it is cancelable. • This can only be used if an Extension is registered with pre-defined task list and resource list with locale information for tasks. • The client applications can update the task progress and its state.
TaskManager & ScheduledTaskManager • TaskManager is the service interface that provides necessary properties and methods for task management. • Find recent tasks • Create task collectors • Find the maximum number of task collectors that can exist simultaneously per client session • ScheduledTaskManager is the service interface that provides necessary methods for creating scheduled tasks. • Find all scheduled tasks • Create new scheduled tasks • Find all the scheduled tasks defined for an entity
TaskManager Managed Object 89% of all virtualized applications in the world run on VMware. tr, December 2008
Retrieving Information about Tasks • TaskManager managed object’s ‘recentTask’ contains a list of Task managed objects that completed recently (in the last 10 minutes), that are currently running and queued to run. • vCenter Server persists information about all the tasks for all the hosts that it is managing. • vSphere SDK client programs can retrieve information about any Task from the vCenter Server. • TaskHistoryCollector is similar to EventHistoryCollector that can retrieve TaskInfo of the historical tasks. • Information related to Tasks can be filtered based on a specific managed entity, window of time, user name, alarm, task state etc. • TaskHistoryCollector is session specific.
Alarms • Alarms are associated with one or more managed entities. • Alarms let you trigger actions based on specific conditions, state or event. • Every alarm must have an expression that evaluates to a boolean value. • Types of actions that can be triggered using an alarm: • Send an SNMP trap • Send an email • Run a shell script in the vCenter Server (fully-qualified path to the shell script must be provided) • Invoke other vSphere APIs (the name must match with the name in the WSDL) • Create a custom task
AlarmManager • AlarmManager is the service interface methods for alarm management. • Create alarms. • Check if the alarm actions are enabled / disabled. • Enable / disable alarm actions. • Get Alarm objects defined on an entity. • Information about the alarm state.
AlarmManager Managed Object 89% of all virtualized applications in the world run on VMware. tr, December 2008
Creating an Alarm • Creating an alarm requires obtaining the managed object reference to the managed entity to which it is associated and creating AlarmSpec data object. • AlarmSpec data object is used: • To specify the alarm expression that defines the triggering conditions • Alarm settings for tolerance range and reporting frequency • The action to perform when the alarm is triggered (more than one action can be performed, but the order is not guaranteed) • Whether the alarm is enabled or disabled • AlarmExpression defines the triggering conditions. • AlarmExpression is created using data from events, performance statistics, or state of a managed entity. • Multiple AlarmExpression objects can be used in either an ‘AND’ or ‘OR’ relationship while creating an alarm. • Alarms can be enabled or disabled on managed entities.
Code Snippet Using createAlarm API • public voidusingCreateAlarm(String myEventMsg) { • EevntAlarmExpression eae = new EventAlarmExpression(); • eae.setEventType(“com.xxx.yyy.MyEvent”); • eae.setEevntTypeId (“com.xxx.yyy.MyEvent”); • AlarmSpec alarmSpec = new AlarmSpec(); • alarmSpec.setDescription(“Test alarm”); • alarmSpec.setEnabled(true); • alarmSpec.setExpression(eae); • alarmSpec.setName(“MyAlarm_1”); • vimPort.createAlarm(alarmMgr, moRef, alarmSpec); • }
Summary • Events: • Convey information about changes in the state of managed entities • Historical information can be retrieved and using waitForUpdates API, can send event notifications • Users can create custom events and post them to the vCenter • Tasks • Asynchronous operations performed on managed entities • Are of two types, scheduled and active. • Users can create custom tasks and update their progress • Alarms • Can be associated with one or more managed entities • Allows you to trigger some actions based on property changes, state changes, performance statistics and events
Ready. Set. Go! Take Action • GO! Get Educated • Visit Partner University for information on partner programs and resources • Access to VMware Partner Exchange presentations • GO! Get Competent • Enroll in training and certification that counts toward earning competencies • GO! Register Your Deals to Earn More Margin • Visit Partner Central to learn about VMware’s registration programs