Skip to content

rvrdata.adapters.infoblox_ddi_csv

Data adapter for Infoblox DDI CSV files.

Infoblox DDI uses a special format for comma-separate value files. The CSV Import Reference provides more detail about how data is structured for imports. Specifically see the CSV File Format for more detail on the special format of the csv files with header info.

For more information about how Infoblox DDI uses csv files, see https://docs.infoblox.com/space/nios84/44600724/Importing+and+Exporting+Data+using++CSV+Import

class RvrdataInfoblox_Ddi_Csv

Data adapter for comma-separated value (.csv) files for Infoblox DDI.

bind_to_ddi()

Convert a data object created by the bind adapter to a DDI data object.

The resulting records are formatted ready for csv import into Infoblox DDI with the required header fields and records mapped to header names. They can be written to a file using the infoblox_ddi_csv.write action.

  • Parameters:
  • bind_object – The dict containing a records list of data objects to convert.
  • rtypes (list) – List of permitted record types to convert. Defaults to “A”, “AAAA”, “CNAME”, “PTR”, “TXT”, “MX”, and “SRV”.
  • create_ptr_records (bool) – Indicates whether to auto-create PTRs (defaults to False).
  • arecord_fields (dict) – Collection of A records.
  • aaaarecord_fields (dict) – Optional collection of AAAA records.
  • cnamerecord_fields (dict) – Optional collection of CNAME records.
  • ptrrecord_fields (dict) – Optional collection of PTR records.
  • txtrecord_fields (dict) – Optional collection of TXT records.
  • mxrecord_fields (dict) – Optional collection of MX records.
  • srvrecord_fields (dict) – Optional collection of SRV records.
  • extra_fields (dict) – Optional collection of extra fields.

See the bind adapter for more detail on zone files.

Optional DDI extra import fields may be passed in “extra_fields”, such as “disabled”, “view” or any “EA-” labels. These key/value pairs are NOT checked for legality and will be processed as-is. Refer to: https://docs.infoblox.com/display/nios85/Supported+Object+Types

Any supplied kwarg fields will be applied to all objects of the specified record type, except for extra_fields, which are applied to all objects, regardless of record type.

  • Returns: List of dicts of record data formatted for CSV import into Infoblox DDI.

Bind to DDI Metrics

The following metrics are included in the step results:

  • rvrdata.dataflow.action.infoblox_ddi_csv.bind_to_ddi.size: Size of data in bytes (int).
  • rvrdata.dataflow.action.infoblox_ddi_csv.bind_to_ddi.line_count: Number of records written (int).
  • rvrdata.dataflow.action.infoblox_ddi_csv.bind_to_ddi.file_count: Number of files written (int).

One row is added to the metrics each time the action is run.

read()

Read comma-separated value file in Infoblox DDI format into memory.

  • Parameters:
  • filename (str) – Path to file.
  • kwargs (Any) – Pass-through of keyword arguments to csv.reader().
  • Returns: success=True if the file is read.

The action infoblox_ddi_csv.read in a dataflow step reads the contents of a csv file into the .data property of the step.

If the filename is not correct or the file is not accessible due to permissions, this action will fail.

Example: Dataflow reading a csv file in Infoblox DDI format

steps:
  - name: get_ddi_csv
    notes: Load csv file contents into 'steps.get_ddi_csv.data'.
    action: infoblox_ddi_csv.read
    params:
        filename: "data/example_ddi_format.csv"

This looks for lines in the .csv file that start with ‘header-’ to determine if they are lines with header definitions, otherwise they are treated as records. All record lines should have a header value in the first column. These values should map to a corresponding header that they can be mapped to or else they are ignored.

See CSV File Example to see the format Infoblox DDI NIOS uses with multiple types of rows.

See csv.reader for more information about how reading csv file behaves. Any keywords can be passed through to the function under params.

Read Metrics

The following metrics are included in the step results:

  • rvrdata.dataflow.action.infoblox_ddi_csv.read.size: Size of csv data in bytes (int).
  • rvrdata.dataflow.action.infoblox_ddi_csv.read.line_count: Number of records read excluding header row (int).
  • rvrdata.dataflow.action.infoblox_ddi_csv.read.file_count: Number of files read (int).

One row is added to the metrics each time the action is run.

write()

Write Infoblox DDI CSV formatted file.

  • Parameters:
  • filename (str) – Path to file.
  • data (list) – Array of dictionary records.
  • kwargs – Pass-through of keyword arguments to csv.writer().

Creates a file consisting of header rows which define column names, and record rows with data and the first column mapped to headers.

See CSV File Multi-record Example to see the format Infoblox DDI NIOS uses.

Write Metrics

The following metrics are included in the step results:

  • rvrdata.dataflow.action.infoblox_ddi_csv.write.size: Size of csv data in bytes (int).
  • rvrdata.dataflow.action.infoblox_ddi_csv.write.line_count: Number of records written (int).
  • rvrdata.dataflow.action.infoblox_ddi_csv.write.file_count: Number of files written (int).

One row is added to the metrics each time the action is run.

create()

Create new comma-separated value file only if it is not already present.

This action works similar to a POST action in a REST API. It is intended for situations that need to avoid overwriting existing data. This will fail if there is an existing file in the path specified.

Syntax is the same as infoblox_ddi_csv.write.

See infoblox_ddi_csv.write metrics for create metrics.

delete()

Delete file.

This works the same as text.delete.

Delete Metrics

The following metrics are included in the step results:

  • rvrdata.dataflow.action.infoblox_ddi_csv.delete.file_count: Number of files deleted (int).

One row is added to the metrics each time the action is run.

update()

Update comma-separated value file with supplied data.

  • Parameters:
  • filename (str) – Path to csv file
  • data (Any) – Data to be appended

Note: This is to be deprecated and replaced by an append function.

See infoblox_ddi_csv.write metrics for update metrics.

force_pass()

Fake successful action that does nothing.

See force_pass in stdout adapter.