ztpserver Package — ZTP Server 1.0 documentation

### Navigation

- index
- modules |
- ZTP Server 1.0 documentation »

# ztpserver Package

## `ztpserver` Package

## `app` Module

## `config` Module

class `ztpserver.config.` `Attr`(name, **kwargs)

  Bases: `object`

  Base Attribute class for deriving all attributes for a Config object

  Parameters: | name – required argument specifies attribute name type – optional keyword argument specifies attribute type. the default argument type is String group – optional keyword argument specifies attribute group. All attribute names must be unique within the group default – optional keyword argument specifies the default value for the attribute. The default value is None

class `ztpserver.config.` `BoolAttr`(name, **kwargs)

  Bases: `ztpserver.config.Attr`

  Boolean attribute class derived from Attr

class `ztpserver.config.` `Config`

  Bases: `_abcoll.Mapping`

  The Config class represents the configuration for collection.

  `add_attribute`(item, group=None)
  `add_group`(group)
  `clear_value`(name, group=None)

    clears the attributes value and resets it to default

  `read`(filename)
  `set_value`(name, value, group=None)

class `ztpserver.config.` `Group`(name, config)

  Bases: `_abcoll.Mapping`

  The Group class provides a logical grouping of attributes in a Config object. Group names must be unique for each Config instance and cannot be assigned values.

  Parameters: | name – the name of the group config – the config object the group is associated with

  `add_attribute`(item)

class `ztpserver.config.` `IntAttr`(name, minvalue=None, maxvalue=None, **kwargs)

  Bases: `ztpserver.config.Attr`

  Integer attribute class derived from Attr

  Parameters: | minvalue – specifies the min value. the default is None maxvalue – specifies the max value. the default is None

class `ztpserver.config.` `ListAttr`(name, delimiter=', ', **kwargs)

  Bases: `ztpserver.config.Attr`

  List attribute class derived from Attr

  Parameters: | delimiter – specifies the delimiter character to split the string on

class `ztpserver.config.` `StrAttr`(name, choices=None, **kwargs)

  Bases: `ztpserver.config.Attr`

  String attribute class derived from Attr

  Parameters: | choices – optional keyword argument specifies valid choices

## `controller` Module

## `topology` Module

class `ztpserver.topology.` `Collection`

  Bases: `_abcoll.Mapping`, `_abcoll.Callable`

exception `ztpserver.topology.` `DataFileError`

  Bases: `exceptions.Exception`

class `ztpserver.topology.` `DataFileMixin`

  Bases: `object`

  `deserialize`()
  `dump`(fobj, data, content_type='text/plain')
  `dumps`(data, content_type='text/plain')
  `load`(fobj, content_type='text/plain')
  `loads`(data, content_type='text/plain')
  `serialize`()

class `ztpserver.topology.` `Functions`

  Bases: `object`

  classmethod `exact`(arg, value)
  classmethod `excludes`(arg, value)
  classmethod `includes`(arg, value)
  classmethod `regex`(arg, value)

class `ztpserver.topology.` `InterfacePattern`(interface, device, port, tags=None)

  Bases: `object`

  `match_device`(device, variables={})
  `match_neighbors`(neighbors, variables)
  `match_port`(port)
  `range`(interface_range)
  `serialize`()

class `ztpserver.topology.` `Node`(**kwargs)

  Bases: `object`

  class `Neighbor`

    Bases: `tuple`

    Neighbor(device, port)

    `device`

      Alias for field number 0

    `port`

      Alias for field number 1

  `Node.` `add_neighbors`(neighbors)
  `Node.` `convert`(data)
  `Node.` `hasneighbors`()
  `Node.` `serialize`()

exception `ztpserver.topology.` `NodeErrror`

  Bases: `exceptions.Exception`

class `ztpserver.topology.` `OrderedCollection`(*args, **kwds)

  Bases: `collections.OrderedDict`, `_abcoll.Callable`

class `ztpserver.topology.` `Pattern`(name, definition, **kwargs)

  Bases: `object`

  `add_interface`(interface, device, port, tags=None)
  `add_interfaces`(interfaces)
  `deserialize`(contents)
  `load`(filename, content_type='application/yaml')
  `match_node`(node, variables={})
  `serialize`()

exception `ztpserver.topology.` `PatternError`

  Bases: `exceptions.Exception`

class `ztpserver.topology.` `Resources`

  Bases: `object`

  `allocate`(pool, node)
  `dump`(data, fobj, content_type='application/yaml')
  `dumps`(data, pool, content_type='application/yaml')
  `load`(fobj, content_type='application/yaml')
  `loads`(data, content_type='application/yaml')
  `lookup`(pool, node)

class `ztpserver.topology.` `Topology`(contents=None)

  Bases: `object`

  `add_pattern`(pattern)
  `deserialize`(contents)
  `get_patterns`(node)

    returns a list of possible patterns for a given node

  `load`(fobj, content_type='application/yaml')
  `loads`(data, content_type='application/yaml')
  `match_node`(node)

    Returns a list of `Pattern` classes satisfied by the `Node` argument

exception `ztpserver.topology.` `TopologyError`

  Bases: `exceptions.Exception`

`ztpserver.topology.` `clear`()

`ztpserver.topology.` `create_node`(nodeattrs)

`ztpserver.topology.` `default_filename`()

`ztpserver.topology.` `load`(filename=None, content_type='application/yaml')

`ztpserver.topology.` `loads`(data, content_type='application/yaml')

`ztpserver.topology.` `resources`(attributes, node)

## `repository` Module

class `ztpserver.repository.` `FileObject`(name, path=None)

  Bases: `object`

  represents a file object from the file store

  `contents`
  `exists`

exception `ztpserver.repository.` `FileObjectNotFound`

  Bases: `exceptions.Exception`

  raised if url not found in the file store

class `ztpserver.repository.` `FileStore`(path)

  Bases: `object`

  represents the file store

  `add_file`(filepath)
  `add_folder`(folderpath)
  `delete_file`(filepath)
  `exists`(filepath)
  `get_file`(filepath)
  `write_file`(filepath, contents, binary=False)

exception `ztpserver.repository.` `FileStoreError`

  Bases: `exceptions.Exception`

  base exception class for FileStore objects

`ztpserver.repository.` `create_file_store`(name, basepath=None)

  creates a new FileStore object

`ztpserver.repository.` `create_node`(headers)

  returns a Node object using HTTP X-Arista headers

## `serializers` Module

class `ztpserver.serializers.` `JSONSerializer`

  Bases: `object`

  `deserialize`(data, **kwargs)
  `serialize`(data, **kwargs)

class `ztpserver.serializers.` `Serializer`

  Bases: `object`

  The `Serializer` will serialize a data structure based on the content-type. If the content-type is not supported the `Serializer` will simply return the data as a `str` object

  `convert`(data)
  `deserialize`(data, content_type, clsobj=None, **kwargs)

    deserialize the data based on the content_type

    If a valid handler does not exist for the requested content_type, then the data is returned as a string

    Parameters: | data – data to be deserialized content_type – string specifies the deserialize handler to use clsobj – class object to return if specified

  `serialize`(data, content_type, **kwargs)

    serialize the data base on the content_type

    If a valid handler does not exist for the requested content_type, then the data is returned as a string

    Parameters: | data – data to be serialized content_type – string specifies the serialize handler to use

exception `ztpserver.serializers.` `SerializerError`

  Bases: `exceptions.Exception`

  base error raised by serialization functions

class `ztpserver.serializers.` `YAMLSerializer`

  Bases: `object`

  The `YAMLSerializer` class will generate a RuntimeWarning if the PyYaml module is unavialable

  `deserialize`(data, **kwargs)
  `serialize`(data, safe_dump=False, **kwargs)

## `types` Module

class `ztpserver.types.` `Boolean`

  Bases: `object`

  `FALSEVALUES` = ['no', 'false', '0', 'off']
  `TRUEVALUES` = ['yes', 'true', '1', 'on']

class `ztpserver.types.` `Integer`(minvalue=None, maxvalue=None)

  Bases: `object`

class `ztpserver.types.` `List`(delimiter=', ')

  Bases: `object`

class `ztpserver.types.` `String`(choices=None)

  Bases: `object`

## `wsgiapp` Module

### Navigation

- index
- modules |
- ZTP Server 1.0 documentation »