Пример #1
0
    def create(self, id, sdata):
        sdata.getSession().addYangSessionPreReserveProcessor(self.create_pre_processor)

        #Fetch Local Config Object
        config = getCurrentObjectConfig(id, sdata, 'flow_record')

        #Fetch Service Model Context Object
        smodelctx = None

        #Fetch Parent Object
        parentobj = None

        dev = []
        inputkeydict = {}
        devbindobjs={}
        inputdict = {}
        opaque_args = self.opaque_args

        # START OF FETCHING THE LEAF PARAMETERS
        inputdict['name'] = config.get_field_value('name')
        inputdict['record_type'] = config.get_field_value('record_type')
        inputdict['description'] = config.get_field_value('description')
        # END OF FETCHING THE LEAF PARAMETERS

        _Gen_obj = getLocalObject(sdata, 'day1service')
        device_mgmt_ip_address = _Gen_obj.day1service.device_ip

        #Fetch Device Object
        dev = getDeviceObject(device_mgmt_ip_address, sdata)

        # START OF FETCHING THE PARENT KEY LEAF PARAMETERS
        inputkeydict['day1services_day1service_device_ip'] = sdata.getRcPath().split('/')[-5].split('=')[1]
        # END OF FETCHING THE PARENT KEY LEAF PARAMETERS

        #Use the custom methods to process the data
        service_customization.ServiceDataCustomization.process_service_create_data(smodelctx, sdata, dev, id=id, device=dev, parentobj=parentobj, inputdict=inputdict, inputkeydict=inputkeydict, config=config, hopaque=opaque_args)

        #Start of Device binding with python bindings
        #netflow_object = devices.device.netflow.netflow()
        netflow_object = netflow.netflow()
        #netflow_flow_records_object = devices.device.netflow.flow_records.flow_records()
        netflow_flow_records_object = netflow.flow_records.flow_records()
        if util.isNotEmpty(inputdict.get('name')):
          #netflow_flow_records_flow_record_object = devices.device.netflow.flow_records.flow_record.flow_record()
          netflow_flow_records_flow_record_object = netflow.flow_records.flow_record.flow_record()
          netflow_flow_records_flow_record_object.name = inputdict.get('name')
          netflow_flow_records_flow_record_object.description = inputdict.get('description')
          netflow_flow_records_flow_record_object.record_type = inputdict.get('record_type')


        #End of Device binding
        devbindobjs['netflow_flow_records_flow_record_object'] = netflow_flow_records_flow_record_object
        #Use the custom method to process/create payload
        service_customization.ServiceDataCustomization.process_service_device_bindings(smodelctx, sdata, dev, id=id, device=dev, inputdict=inputdict, inputkeydict=inputkeydict, parentobj=parentobj, config=config, devbindobjs=devbindobjs, hopaque=opaque_args)
        for dev_iterator in dev:
            if dev_iterator.device.get_field_value('netflow') == None:
                yang.Sdk.createData(dev_iterator.url,'<netflow/>', sdata.getSession(), True)

            if not yang.Sdk.dataExists(dev_iterator.url+'/l3features:netflow/flow-records'):
                yang.Sdk.createData(dev_iterator.url+'/l3features:netflow','<flow-records/>', sdata.getSession(), False)


        netflow_flow_records_flow_record_object_payload = netflow_flow_records_flow_record_object.getxml(filter=True)
        log('netflow_flow_records_flow_record_object_payload: %s' % (netflow_flow_records_flow_record_object_payload))
        for dev_iterator in dev:
          yang.Sdk.createData(dev_iterator.url+'/l3features:netflow/flow-records',netflow_flow_records_flow_record_object_payload, sdata.getSession(), True)
Пример #2
0
    def create(self, id, sdata):
        sdata.getSession().addYangSessionPreReserveProcessor(
            self.create_pre_processor)

        #Fetch Local Config Object
        config = getCurrentObjectConfig(id, sdata, 'flow_exports')

        #Fetch Service Model Context Object
        smodelctx = None

        #Fetch Parent Object
        parentobj = None

        dev = []
        inputkeydict = {}
        devbindobjs = {}
        inputdict = {}
        opaque_args = self.opaque_args

        # START OF FETCHING THE LEAF PARAMETERS
        inputdict['legacy_netflow'] = config.get_field_value('legacy_netflow')
        if inputdict.get('legacy_netflow') is None:
            inputdict['legacy_netflow'] = 'False'
        inputdict['source'] = config.get_field_value('source')
        inputdict['interface_names'] = config.get_field_value(
            'interface_names')
        inputdict['version'] = config.get_field_value('version')
        # END OF FETCHING THE LEAF PARAMETERS

        _Gen_obj = getLocalObject(sdata, 'day1service')
        device_mgmt_ip_address = _Gen_obj.day1service.device_ip

        #Fetch Device Object
        dev = getDeviceObject(device_mgmt_ip_address, sdata)

        # START OF FETCHING THE PARENT KEY LEAF PARAMETERS
        inputkeydict['day1services_day1service_device_ip'] = sdata.getRcPath(
        ).split('/')[-4].split('=')[1]
        # END OF FETCHING THE PARENT KEY LEAF PARAMETERS

        #Use the custom methods to process the data
        service_customization.ServiceDataCustomization.process_service_create_data(
            smodelctx,
            sdata,
            dev,
            parentobj=parentobj,
            inputdict=inputdict,
            inputkeydict=inputkeydict,
            config=config,
            hopaque=opaque_args)

        #Start of Device binding with python bindings
        netflow_object = netflow.netflow()
        netflow_flow_exports_object = netflow.flow_exports.flow_exports()
        netflow_flow_exports_object.legacy_netflow = inputdict.get(
            'legacy_netflow')
        netflow_flow_exports_object.source = inputdict.get('source')
        netflow_flow_exports_object.interface_names = inputdict.get(
            'interface_names')
        netflow_flow_exports_object.version = inputdict.get('version')

        #End of Device binding
        devbindobjs[
            'netflow_flow_exports_object'] = netflow_flow_exports_object
        #Use the custom method to process/create payload
        service_customization.ServiceDataCustomization.process_service_device_bindings(
            smodelctx,
            sdata,
            dev,
            inputdict=inputdict,
            inputkeydict=inputkeydict,
            parentobj=parentobj,
            config=config,
            devbindobjs=devbindobjs,
            hopaque=opaque_args)
        for dev_iterator in dev:
            if dev_iterator.device.get_field_value('netflow') == None:
                yang.Sdk.createData(dev_iterator.url, '<netflow/>',
                                    sdata.getSession(), False)

        netflow_flow_exports_object_payload = netflow_flow_exports_object.getxml(
            filter=True)
        log('netflow_flow_exports_object_payload: %s' %
            (netflow_flow_exports_object_payload))
        for dev_iterator in dev:
            yang.Sdk.createData(dev_iterator.url + '/l3features:netflow',
                                netflow_flow_exports_object_payload,
                                sdata.getSession(), True)
Пример #3
0
    def create(self, id, sdata):
        sdata.getSession().addYangSessionPreReserveProcessor(
            self.create_pre_processor)

        #Fetch Local Config Object
        config = getCurrentObjectConfig(id, sdata, 'options')

        #Fetch Service Model Context Object
        smodelctx = None

        #Fetch Parent Object
        parentobj = None
        rcpath = util.get_parent_rcpath(sdata.getRcPath(), level=1)
        xml_output = yang.Sdk.getData(rcpath, '', sdata.getTaskId())
        parentobj = util.parseXmlString(xml_output)

        dev = []
        inputkeydict = {}
        devbindobjs = {}
        inputdict = {}
        opaque_args = self.opaque_args

        # START OF FETCHING THE LEAF PARAMETERS
        inputdict['option'] = config.get_field_value('option')
        # END OF FETCHING THE LEAF PARAMETERS

        _Gen_obj = getLocalObject(sdata, 'day1service')
        device_mgmt_ip_address = _Gen_obj.day1service.device_ip

        if hasattr(parentobj.flow_export, 'name'):
            inputdict[
                'netflow_flow_exports_flow_export_name'] = parentobj.flow_export.name
        #Fetch Device Object
        dev = getDeviceObject(device_mgmt_ip_address, sdata)

        # START OF FETCHING THE PARENT KEY LEAF PARAMETERS
        inputkeydict[
            'day1services_day1service_netflow_netflow_flow_exports_flow_export_name'] = sdata.getRcPath(
            ).split('/')[-2].split('=')[1]
        inputkeydict['day1services_day1service_device_ip'] = sdata.getRcPath(
        ).split('/')[-6].split('=')[1]
        # END OF FETCHING THE PARENT KEY LEAF PARAMETERS

        #Use the custom methods to process the data
        service_customization.ServiceDataCustomization.process_service_create_data(
            smodelctx,
            sdata,
            dev,
            id=id,
            device=dev,
            parentobj=parentobj,
            inputdict=inputdict,
            inputkeydict=inputkeydict,
            config=config,
            hopaque=opaque_args)

        #Start of Device binding with python bindings
        #netflow_object = devices.device.netflow.netflow()
        netflow_object = netflow.netflow()
        #netflow_flow_exports_object = devices.device.netflow.flow_exports.flow_exports()
        netflow_flow_exports_object = netflow.flow_exports.flow_exports()
        if util.isNotEmpty(
                inputdict.get('netflow_flow_exports_flow_export_name')):
            #netflow_flow_exports_flow_export_object = devices.device.netflow.flow_exports.flow_export.flow_export()
            netflow_flow_exports_flow_export_object = netflow.flow_exports.flow_export.flow_export(
            )
            if util.isNotEmpty(inputdict.get('option')):
                #netflow_flow_exports_flow_export_options_object = devices.device.netflow.flow_exports.flow_export.options.options()
                netflow_flow_exports_flow_export_options_object = netflow.flow_exports.flow_export.options.options(
                )
                netflow_flow_exports_flow_export_options_object.option = inputdict.get(
                    'option')

        #End of Device binding
        devbindobjs[
            'netflow_flow_exports_flow_export_options_object'] = netflow_flow_exports_flow_export_options_object
        #Use the custom method to process/create payload
        service_customization.ServiceDataCustomization.process_service_device_bindings(
            smodelctx,
            sdata,
            dev,
            id=id,
            device=dev,
            inputdict=inputdict,
            inputkeydict=inputkeydict,
            parentobj=parentobj,
            config=config,
            devbindobjs=devbindobjs,
            hopaque=opaque_args)

        netflow_flow_exports_flow_export_options_object_payload = netflow_flow_exports_flow_export_options_object.getxml(
            filter=True)
        log('netflow_flow_exports_flow_export_options_object_payload: %s' %
            (netflow_flow_exports_flow_export_options_object_payload))
        for dev_iterator in dev:
            yang.Sdk.createData(
                dev_iterator.url +
                '/l3features:netflow/flow-exports/flow-export=%s' %
                (util.make_interfacename(
                    inputdict.get('netflow_flow_exports_flow_export_name'))),
                netflow_flow_exports_flow_export_options_object_payload,
                sdata.getSession(), True)
Пример #4
0
    def create(self, id, sdata):
        sdata.getSession().addYangSessionPreReserveProcessor(
            self.create_pre_processor)

        #Fetch Local Config Object
        config = getCurrentObjectConfig(id, sdata, 'exporter')

        #Fetch Service Model Context Object
        smodelctx = None

        #Fetch Parent Object
        parentobj = None

        dev = []
        inputkeydict = {}
        devbindobjs = {}
        inputdict = {}
        opaque_args = self.opaque_args

        # START OF FETCHING THE LEAF PARAMETERS
        inputdict['exporter'] = config.get_field_value('exporter')
        # END OF FETCHING THE LEAF PARAMETERS

        _Gen_obj = getLocalObject(sdata, 'day1service')
        device_mgmt_ip_address = _Gen_obj.day1service.device_ip

        #Fetch Device Object
        dev = getDeviceObject(device_mgmt_ip_address, sdata)

        # START OF FETCHING THE PARENT KEY LEAF PARAMETERS
        inputkeydict[
            'day1services_day1service_netflow_netflow_flow_monitors_flow_monitor_name'] = sdata.getRcPath(
            ).split('/')[-3].split('=')[1]
        inputkeydict['day1services_day1service_device_ip'] = sdata.getRcPath(
        ).split('/')[-7].split('=')[1]
        # END OF FETCHING THE PARENT KEY LEAF PARAMETERS

        #Use the custom methods to process the data
        service_customization.ServiceDataCustomization.process_service_create_data(
            smodelctx,
            sdata,
            dev,
            id=id,
            device=dev,
            parentobj=parentobj,
            inputdict=inputdict,
            inputkeydict=inputkeydict,
            config=config,
            hopaque=opaque_args)

        #Start of Device binding with python bindings
        #netflow_object = devices.device.netflow.netflow()
        netflow_object = netflow.netflow()
        #netflow_flow_monitors_object = devices.device.netflow.flow_monitors.flow_monitors()
        netflow_flow_monitors_object = netflow.flow_monitors.flow_monitors()
        _Gen_obj = getLocalObject(sdata, 'flow-monitor')
        inputdict[
            'day1services_day1service_netflow_netflow_flow_monitors_flow_monitor_name'] = _Gen_obj.flow_monitor.name
        if util.isNotEmpty(
                inputdict.get(
                    'day1services_day1service_netflow_netflow_flow_monitors_flow_monitor_name'
                )):
            #netflow_flow_monitors_flow_monitor_object = devices.device.netflow.flow_monitors.flow_monitor.flow_monitor()
            netflow_flow_monitors_flow_monitor_object = netflow.flow_monitors.flow_monitor.flow_monitor(
            )
            #netflow_flow_monitors_flow_monitor_exporters_object = devices.device.netflow.flow_monitors.flow_monitor.exporters.exporters()
            netflow_flow_monitors_flow_monitor_exporters_object = netflow.flow_monitors.flow_monitor.exporters.exporters(
            )
            if util.isNotEmpty(inputdict.get('exporter')):
                #netflow_flow_monitors_flow_monitor_exporters_exporter_object = devices.device.netflow.flow_monitors.flow_monitor.exporters.exporter.exporter()
                netflow_flow_monitors_flow_monitor_exporters_exporter_object = netflow.flow_monitors.flow_monitor.exporters.exporter.exporter(
                )
                netflow_flow_monitors_flow_monitor_exporters_exporter_object.exporter = inputdict.get(
                    'exporter')

        #End of Device binding
        devbindobjs[
            'netflow_flow_monitors_flow_monitor_exporters_exporter_object'] = netflow_flow_monitors_flow_monitor_exporters_exporter_object
        #Use the custom method to process/create payload
        service_customization.ServiceDataCustomization.process_service_device_bindings(
            smodelctx,
            sdata,
            dev,
            id=id,
            device=dev,
            inputdict=inputdict,
            inputkeydict=inputkeydict,
            parentobj=parentobj,
            config=config,
            devbindobjs=devbindobjs,
            hopaque=opaque_args)
        for dev_iterator in dev:
            yang.Sdk.createData(
                dev_iterator.url + '/netflow/flow-monitors/flow-monitor=%s' %
                (util.make_interfacename(
                    inputdict.get(
                        'day1services_day1service_netflow_netflow_flow_monitors_flow_monitor_name'
                    ))), '<exporters/>', sdata.getSession(), True)

        netflow_flow_monitors_flow_monitor_exporters_exporter_object_payload = netflow_flow_monitors_flow_monitor_exporters_exporter_object.getxml(
            filter=True)
        log('netflow_flow_monitors_flow_monitor_exporters_exporter_object_payload: %s'
            %
            (netflow_flow_monitors_flow_monitor_exporters_exporter_object_payload
             ))
        for dev_iterator in dev:
            yang.Sdk.createData(
                dev_iterator.url +
                '/l3features:netflow/flow-monitors/flow-monitor=%s/exporters' %
                (util.make_interfacename(
                    inputdict.get(
                        'day1services_day1service_netflow_netflow_flow_monitors_flow_monitor_name'
                    ))),
                netflow_flow_monitors_flow_monitor_exporters_exporter_object_payload,
                sdata.getSession(), True)
Пример #5
0
    def update(self, id, sdata):
        #Fetch Local Config Object
        config = getCurrentObjectConfig(id, sdata, 'flow_export')
        opaque_args = self.opaque_args

        #Fetch Service Model Context Object
        smodelctx = None

        #Fetch Parent Object
        parentobj = None

        dev = []
        inputkeydict = {}
        devbindobjs = {}
        inputdict = {}
        opaque_args = self.opaque_args

        # START OF FETCHING THE LEAF PARAMETERS
        inputdict['name'] = config.get_field_value('name')
        inputdict['description'] = config.get_field_value('description')
        inputdict['destination'] = config.get_field_value('destination')
        inputdict['source'] = config.get_field_value('source')
        inputdict['vrf'] = config.get_field_value('vrf')
        inputdict['udp_port_value'] = config.get_field_value('udp_port_value')
        inputdict['template_timeout'] = config.get_field_value(
            'template_timeout')
        # END OF FETCHING THE LEAF PARAMETERS

        _Gen_obj = getLocalObject(sdata, 'day1service')
        device_mgmt_ip_address = _Gen_obj.day1service.device_ip

        #Fetch Device Object
        dev = getDeviceObject(device_mgmt_ip_address, sdata)

        prevconfig = util.parseXmlString(sdata.getPreviousPayload())

        prevconfigflowexp = prevconfig.flow_export

        #Start of Device binding with python bindings
        netflow_object = netflow.netflow()
        netflow_flow_exports_object = netflow.flow_exports.flow_exports()

        netflow_flow_exports_flow_export_object = netflow.flow_exports.flow_export.flow_export(
        )
        netflow_flow_exports_flow_export_object.name = prevconfigflowexp.get_field_value(
            'name')
        netflow_flow_exports_flow_export_object.description = inputdict.get(
            'description')
        netflow_flow_exports_flow_export_object.destination = inputdict.get(
            'destination')
        netflow_flow_exports_flow_export_object.source = inputdict.get(
            'source')
        netflow_flow_exports_flow_export_object.vrf = inputdict.get('vrf')
        netflow_flow_exports_flow_export_object.udp_port_value = inputdict.get(
            'udp_port_value')
        netflow_flow_exports_flow_export_object.template_timeout = inputdict.get(
            'template_timeout')

        netflow_flow_exports_flow_export_object_payload = netflow_flow_exports_flow_export_object.getxml(
            filter=True)
        #log('netflow_flow_exports_flow_export_object_payload: %s' % (netflow_flow_exports_flow_export_object_payload))
        for dev_iterator in dev:
            yang.Sdk.createData(
                dev_iterator.url + '/l3features:netflow/flow-exports',
                netflow_flow_exports_flow_export_object_payload,
                sdata.getSession(), True)
        #Use the custom method to process the data
        service_customization.ServiceDataCustomization.process_service_update_data(
            smodelctx,
            sdata,
            parentobj=parentobj,
            config=config,
            hopaque=opaque_args,
            inputdict=inputdict)