topology.platforms.platform

Base platform engine module for topology.

This module defines the functionality that a topology platform plugin must provide to be able to create a network using specific hardware or software.

Classes

class topology.platforms.platform.BasePlatform(timestamp, nmlmanager)

Base platform engine class.

This class represent the base interface that topology engines require to implement.

See the Plugins Development Guide for reference.

Parameters:
  • timestamp (str) – Timestamp in ISO 8601 format.
  • nmlmanager (pynml.manager.NMLManager) – Manager holding the NML namespace.

Inheritance

Inheritance diagram of BasePlatform

Add a bidirectional link between given nodes and ports.

This method receives two tuples with the NML nodes and bidirectional ports associated with the bidirectional link and also the NML bidirectional link object that specifies the link required to be added to the platform. This methods returns nothing as the topology users don’t expect to deal directly with links. All interaction is done with the nodes.

Parameters:
  • nodeport_a ((pynml.nml.Node, pynml.nml.BidirectionalPort)) – A tuple (Node, BiPort) of the first endpoint.
  • nodeport_b ((pynml.nml.Node, pynml.nml.BidirectionalPort)) – A tuple (Node, BiPort) of the second endpoint.
  • bilink – The specification NMP bidirectional link to add to the platform.
add_biport(node, biport)

Add a bidirectional port to the given node.

This method receives a NML node and a NML bidirectional port that specifies the port required to be added. This methods returns nothing as the topology users don’t expect to deal directly with ports. All interaction is done with the nodes.

Parameters:
  • node (pynml.nml.Node) – The specification NML node owner of the port.
  • biport (pynml.nml.BidirectionalPort) – The specification NMP bidirectional port to add to the platform.
Return type:

str

Returns:

Real name of the port in the node. This real will be used to populate an internal map between the specification name of the port and the real name, which can be used to reference the port in commands without knowing it’s real name in advance.

add_node(node)

Add a node to your platform.

This method receives a NML node and must return a new Engine Node subclass of BaseNode that implements the communication mechanism with that node.

Parameters:node (pynml.nml.Node) – The specification NML node to add to the platform.
Return type:BaseNode
Returns:Platform specific communication node.
destroy()

Platform destruction hook.

Use this to remove all elements from the platform, perform any clean and return resources.

post_build()

Postamble hook.

This hook is called at the last stage of the topology build. Use it to setup any final requirements or start any service before using the topology.

pre_build()

Preamble hook.

This hook is called at the first stage of the topology build. Use it to setup any requirements your platform has.

Relink back a link specified in the topology.

Parameters:link_id (str) – Link identifier to be recreated.
rollback(stage, enodes, exception)

Platform rollback hook.

This is called when the build fails, possibly by an exception raised in previous hooks.

Parameters:
  • stage (str) – The stage the build failed. One of: - pre_build. - add_node. - add_biport. - add_bilink. - post_build.
  • enodes (OrderedDict of subclasses of BaseNode) – Engine nodes already registered.
  • exception (Exception) – The exception caught during build failure.

Unlink (break) a link specified in the topology.

Parameters:link_id (str) – Link identifier to be undone.