The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SIAM::Driver::Simple - a reference implementation of SIAM Driver

SYNOPSIS

The driver does not connect to any external databases. Instead, it reads all the SIAM objects from its YAML data file.

The top level element in the data file is expected to be an array of objects that are contained in the SIAM root. The following object classes are expected to be contained by the root object:

  • SIAM::Contract

  • SIAM::AccessScope

  • SIAM::User

  • SIAM::Device

  • SIAM::Attribute

Each object definition may have an entry with the key _contains_ which points to an array of contained objects. For example, an SIAM::Contract object is expected to contain one or more SIAM::Service objects.

If a key starts with _compute_, it represents a computable for a given object.

All other keys in the object entry define the object attributes. The values are expected to be strings and numbers. The data file should define all the attributes, including siam.object.id and siam.object.class.

See the file t/driver-simple.data.yaml in SIAM package distribution for reference.

MANDATORY METHODS

The following methods are required by SIAM::Documentation::DriverSpec.

new

Instantiates a new driver object. The method expects a hashref containing the attributes, as follows:

  • Logger

    The logger object is supplied by SIAM.

  • Datafile

    Full path of the YAML data file which defines all the objects for this driver.

connect

Reads the YAML data file

disconnect

Disconnects the driver from its underlying databases.

fetch_attributes

 $status = $driver->fetch_attributes($attrs);

Retrieve the object by ID and populate the hash with object attributes.

fetch_computable

  $value = $driver->fetch_computable($id, $key);

Retrieve a computable. Return empty string if unsupported.

fetch_contained_object_ids

   $ids = $driver->fetch_contained_object_ids($id, 'SIAM::Contract', {
       'match_attribute' => [ 'siam.object.access_scope_id',
                              ['SCOPEID01', 'SCOPEID02'] ]
      }
     );

Retrieve the contained object IDs.

fetch_contained_classes

  $classes = $driver->fetch_contained_classes($id);

Returns arrayref with class names.

fetch_container

  $attr = $driver->fetch_container($id);

Retrieve the container ID and class.

fetch_object_ids_by_attribute

  $list = $driver->fetch_object_ids_by_attribute($classname, $attr, $value);

Returns a list of object IDs which match the attribute value.

set_condition

The method does nothing in this driver, but only issues a debug message.

manifest_attributes

The method returns an arrayref with all known attribute names.

ADDITIONAL METHODS

The following methods are not in the Specification.

debug

Prints a debug message to the logger.

error

Prints an error message to the logger.

object_exists

Takes an object ID and returns true if such object is present in the database.

clone_data

  $data = SIAM::Driver::Simple->clone_data($siam, $callback);

The method takes a SIAM object and a callback reference. It walks through the SIAM data and produces a clone suitable for storing into a YAML file and re-using with SIAM::Driver::Simple.

The callback is a sub reference which is supplied with the object ID as an argument. Only the objects which result in true value are being cloned.

The method is usable for producing a test data out of productive system.

SEE ALSO

SIAM::Documentation::DriverSpec, YAML, Log::Handler