Ockle’s Network Tree Data Structure

The Whole Network Tree

Ockle’s main data structure is a acyclic graph implemented by pygraph, that lives in an instance of networkTree/ServerNetwork.py . This graph holds ServerNodes instances, each one represents a server.

You can build a server network from Ockle’s ini files using the Sever Network Generator

class networkTree.ServerNetwork.ServerNetwork[source]

The class that handles the graph server network

addDependency(server, dependency)[source]

Add a dependency to a server

Parameters:
  • server – the name of the server
  • dependency – the name of the server the former is dependent on
Raises DependencyException:
 

Will raise an exception if there was a cycle in the server network

addServer(node, dependencies=[])[source]

Add a server to the network

Parameters:
  • node – a server in the network
  • dependencies – list of the server names this sever is dependent on
allOff()[source]

Turn all servers off ungracefully

getDependencies(server)[source]

Get a list of servers a given server is dependent on (only one level)

Parameters:server – the server name
getDependent(server)[source]

Get a list of servers that are dependent on this server

Parameters:server – the server name
getRoot()[source]

Gets the root server of the tree

Returns:the root server
getServer(serverNameSearch)[source]

Get a server by name

Parameters:serverNameSearch – The server to search for
Returns:The server class, None if not found
getServernode(serverName)[source]

Get a server node by name

Parameters:serverName – The name of the server node
Returns:The server node
getSortedNodeList()[source]

returns a list of the nodes topologically sorted

Returns:a list of the nodes topologically sorted
getSortedNodeListIndex()[source]

returns a list of the node names topologically sorted

Returns:a list of the node names topologically sorted
isAllOpState(opState)[source]

Check if all servers are ok

Returns:True if all servers are on
isReadyToTurnOn(server)[source]

Is a server ready to be turned on?

Returns:True if the server is ready to be turned on
removeDependency(server, dependency)[source]

Remove a dependency from a server

Parameters:
  • server – the name of the server
  • dependency – the name of the server the former is dependent on
turnOffServer(serverName)[source]

Turn a server off by name

Parameters:serverName – The server name
turnOnServer(serverName)[source]

Turn a server on by name

Parameters:serverName – The server name
turningOn()[source]
Returns:true if we have any servers that are in intermediate states
updateNetwork()[source]

Updates the opstate of all the nodes and their outlets/tests and controllers

A Server Node Within the Network

The Server Node object holds the global operation state of the server, and methods to control the server as a whole. Server objects are also stored in this instance. Currently server objects are: Outlets, Controls and Tests.

class networkTree.ServerNode.ServerNode(name, outlets=[], tests=[], controls=[])[source]

This class represents a PC in the network

action(actionString, ignoreDeps=False)[source]

Execute an on/off action on the server

Parameters:
  • actionString – Either “on” or “off”
  • ignoreDeps – True if you want to ignore other server dependencies
controlsStillStarting()[source]

Return true if any control is still on SwitcingOn OpState

getControlsDataDict()[source]

Get the data dict of all the controls

Returns:the controls data dict
getFailedTests()[source]

return a list of failed tests

getNotControlsOpState(opState)[source]

Returns controls that don’t have a given opState

Parameters:opState
Returns:controls that don’t have a given state
getNotOutletsOpState(opState)[source]

Returns outlets that don’t have a given opState

Parameters:opState
Returns:outlets that don’t have a given state
getOutlet(number)[source]

Get an outlet from the outlet list

:param number outlet number in the list :return: an outlet type that is in the given place

getOutlets()[source]

Get a list of outlet numbers @return: a list of outlets

getOutletsDataDict()[source]

Returns a dict that holds all the outlets and their data dict. This gets sent to the logger

Returns:A dict with each outlet name, and a dict of its data
getShutdownAttempts()[source]

Get number of shutdown attempts

Returns:Number of shutdown attempts
getStartAttempts()[source]

Get number of startup attempts

Returns:Number of startup attempts
incrementShutdownAttempt()[source]

Increment the stop attempt counter

Returns:Number of shutdown attempts
incrementStartAttempt()[source]

Increment the startup attempt counter

Returns:Number of startup attempts
outletsStillStarting()[source]

Return true if any outlet is still on SwitcingOn OpState

setControlOpState(opState)[source]

Set all the controls to a given opState

Parameters:opState – The opState to set the control to
setName(name)[source]

Set the name of the Server :param name: The name ot be set

setOpState(state)[source]

Set the operating state of the server

setOutletsOpState(opState)[source]

Set all the outlets to a given opState

Parameters:opState – The opState to set the outlets to
setOutletsState(state)[source]

Sets the outlets all to a given state by force

Parameters:state – set the outlets to state (boolean)
Returns:A list of outlets the failed (note: you can check with “if not” to see if there was no failure
setState(state)[source]

Set server state

Parameters:state – server state type
turnOn(ignoreDeps=False)[source]

Turn on the server outlets, and check if all services are in order

Parameters:ignoreDeps – True if you want to ignore other server dependencies
updateOpState(runTests=True)[source]

Update all the OpStates and run all tests of the server

Project Versions

Table Of Contents

Previous topic

MainDaemon.py

Next topic

Sever Network Generator

This Page