Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 4 Current »

Description

The vp_scheduler_n_events 1.py script defines a class EventsNSchedule that implements two interfaces: IScheduler and IEventHandler using the zope.interface library. The class is designed to handle event processing and task scheduling. The script sets up logging to record the operations performed by this class, including environment details and current timestamps. This script has no editable parameters. The script is uploaded to the Cloud Services Portal through the Application tab (Cloud Services Portal > Configuration > Integrations > Data Connector > Automations).

This script is utilized when customers upload their own script instead of subscribing to an AppDirect marketplace script. If customers are using automation scripts from the marketplace, there is no need to upload this script. For information on uploading your own scripts for use with Data Connector, see Uploading Python Automation Scripts for Use with the Cloud Services Portal.

Purpose of the Script

The script is primarily used for:

  • Event Processing: Handling and logging events with relevant context information.

  • Task Scheduling: Logging current timestamps and environment details for scheduled tasks.

import zope
import interface
import logging
import os

from datetime import datetime

logging.basicConfig(filename='scheduler_n_event_script.log', encoding='utf-8', level=logging.DEBUG)
log = logging.getLogger('__name__')
#log = logging.getLogger('infoblox_driver')

@zope.interface.implementer(interface.IScheduler, interface.IEventHandler)
class EventsNSchedule:
    def __init__(self, attributes=None):
        pass
        
    def schedule(self, context):
        log.info("Current timestamp: {}".format(datetime.now()))
        log.info("Read environments...")
        env_items = os.environ.items()
        log.info(f"Environment items: {env_items}")

    def process(self, context, event):
        ctx = os.environ.items()
        log.info(f"processing the event\n : {event}\nctx data: {ctx}")


#MyScheduler.schedule('','')

  • No labels