Nodeclass

A Nodeclass can contain either or both of nodes or other nodeclasses (to a maximum depth of 2) - you can pass either a Node or Nodeclass object to many of the functions. (cf. the -N flag to mmlsnodeclass)

Nodeclass Objects support Callback Functions

Description

class arcapix.fs.gpfs.nodeclass.Nodeclass(name, memberNodes=None, memberClasses=None)

The Nodeclass is slightly different from the standard arcapix collection objects, in that it supports add and remove, rather than new and destroy.

Since nodeclass objects can be nested, we have chosen to deviate from the norm, in order to avoid confusion between delete and destroy, which would otherwise result.

Creates a new Node class object, which can be used to either read state from the disk, or to create a new nodeclass.

Parameters:
  • name (str) – The name of the nodeclass to work with
  • memberNodes (list) – A list of nodes which will become members of this nodeclass (either Nodes objects or names)
  • memberClasses (list) – A list of sub-classes which will become members of this nodeclass (either NodeClasses or names)
create()

Create a nodeclass and add the initial nodes (memberNodes) into the nodeclass.

Return type:None
delete()

Removes the nodeclass from GPFS

Return type:None
add(node_or_nodeclass)

Adds a node to the nodeclass.

Parameters:node_or_nodeclass (Node or Nodeclass or str) – Node object that you want to add
Return type:Nothing
remove(node_or_nodeclass)

Remove a node from the nodeclass

Parameters:node_or_nodeclass (Node or Nodeclass or str) – Node object that you would like to remove
Return type:Nothing
replace(memberNodes)

Replace all existing members of the nodeclass.

Parameters:memberNode – A Node or list of nodes that should replace the existing members
change(**kwargs)

Change attributes of the nodes associated with this nodeclass.

Parameters:
  • gateway (bool) – change whether these nodes are a gateway nodes
  • manager (bool) – change whether these nodes are candidates to be managers
  • quorum (bool) – change whether these nodes are quorum nodes
Return type:

Nothing

shutdown(unmountTimeout=None)

Shuts down GPFS on all nodes in the nodeclass

Parameters:unmountTimeout (int) – Time to wait for filesystem(s) to unmount on the nodes. If unmount doesn’t complete within unmountTimeout, the GPFS daemon will shutdown anyway (default=60+3*(num nodes) seconds).
Return type:Nothing
startup(async=False, timeout=60)

Starts up GPFS on all nodes in the nodeclass

Parameters:
  • async (bool) – If True, do not wait for startup (default=False).
  • timeout (int) – Time to wait for the nodes to start up if not async (in seconds) (default=60s)
Return type:

Nothing

Raises:

GPFSError if not async and the nodes aren’t back up within the timeout period

memberNodes

Returns all direct members of the nodeclass

i.e. does not include members of the nodeclasses listed in ‘memberClasses’.

Return type:dict of Node
allMemberNodes

List of all members, including those from subsiduary nodeclasses

i.e. those returned by ‘memberClasses’

Return type:dict of Node
id

Returns the identifier for the nodeclass

Synonym for name

Return type:str
name

Returns the name of the node class

Return type:str
nodeclassType

Returns the type of the node class.

Either ‘system’ or ‘user’.

Return type:str
memberClasses

Returns the list of member class names

Return type:dict of Nodeclass

Examples

Using Nodeclass directly

>>> from arcapix.fs.gpfs import nodeclass
>>> from arcapix.fs.gpfs import Cluster
>>>
>>> # Create a new nodeclass object and create it in GPFS
... myNodeclass = Nodeclass("myNewNodeclass", memberNodes=[node01, node02])
>>> myNodeclass.create()
>>>
>>> # Add all nodes which do not contain 'sn' in their name to the nodeclass
... # create a cluster object
... mycluster = Cluster()
>>>
>>> # We need to pass Node objects to the
... for nodename in self.mycluster.nodes.values():
...     if "sn" not in nodename.name:
...         node = nodename
...                 myNodeclass.add(node)
>>>
>>> # Delete the nodeclass from GPFS
... myNodeclass.delete()