fabric-testbed / InformationModel

FABRIC Information Model library
MIT License
7 stars 1 forks source link

Implement Help() functions for all objects #55

Closed paul-ruth closed 3 years ago

paul-ruth commented 3 years ago

ExperimentTopology, Node, etc. need help() functions

ibaldin commented 3 years ago

Looking at it they already have help() support. You can do help() on any one of them and get an extended documentation. I'm not sure what is being asked for @paul-ruth

help(fu.Node)
Help on class Node in module fim.user.node:
class Node(fim.user.model_element.ModelElement)
 |  Node(*, name: str, node_id: str = None, topo: Any, etype: fim.user.model_element.ElementType = <ElementType.EXISTING: 1>, ntype: fim.slivers.network_node.NodeType = None, site: str = None, **kwargs)
 |  
 |  A basic node of any topology. In addition to public methods the following calls
 |  return various dictionaries or lists:
 |  node.components - returns a dictionary of components by name
 |  node.interfaces - returns a dictionary of interfaces by name
 |  interface_list - returns a list of interfaces
 |  direct_interfaces - returns a dictionary of direct interfaces, i.e. those
 |  not attached to components (mostly relevant to switches, not servers
 |  or VMs)
 |  network_services - returns a dictionary of network_services (mostly relevant
 |  to switches, not servers or VMs)
 |  
 |  Method resolution order:
 |      Node
 |      fim.user.model_element.ModelElement
 |      abc.ABC
 |      builtins.object
 |  
 |  Methods defined here:
 |  
 |  __getattr__(self, item)
 |      Special handling for attributes like 'components' and 'interfaces' -
 |      which query into the model. They return dicts and list
 |      containers. Modifying containers does not affect the underlying
 |      graph mode, but modifying elements of lists or values of dicts does.
 |      :param item:
 |      :return:
 |  
 |  __init__(self, *, name: str, node_id: str = None, topo: Any, etype: fim.user.model_element.ElementType = <ElementType.EXISTING: 1>, ntype: fim.slivers.network_node.NodeType = None, site: str = None, **kwargs)
 |      Don't call this method yourself, call topology.add_node()
 |      node_id will be generated if not provided for experiment topologies
 |      
 |      :param name:
 |      :param node_id:
 |      :param topo:
 |      :param etype: is this supposed to exist or new should be created
 |      :param ntype: node type if it is new
 |      :param site: node site
 |      :param kwargs: any additional properties
 |  
 |  __repr__(self)
 |      Return repr(self).
 |  
 |  __str__(self)
 |      Return str(self).
 |  
 |  add_component(self, *, name: str, node_id: str = None, ctype: fim.slivers.attached_components.ComponentType, model: str, network_service_node_id: str = None, interface_node_ids=None, interface_labels=None, **kwargs) -> fim.user.component.Component
 |      Add a component of specified type, model and name to this node. When working with substrate
 |      topologies you must specify the network_service_node_id and provide a list of interface node ids.
 |      :param name:
 |      :param node_id:
 |      :param ctype:
 |      :param model:
 |      :param name:
 |      :param network_service_node_id: network service identifier for substrate models
 |      :param interface_node_ids: interface identifiers for substrate models
 |      :param interface_labels: list of labels for interfaces in substrate models
 |      :param kwargs: additional properties of the component
 |      :return:
 |  
 |  add_network_service(self, *, name: str, node_id: str = None, nstype: fim.slivers.network_service.ServiceType, **kwargs) -> fim.user.network_service.NetworkService
 |      Add a network service to node (mostly needed in substrate topologies)
 |      :param name:
 |      :param node_id:
 |      :param layer:
 |      :param kwargs:
 |      :return:
 |  
 |  get_component(self, name: str)
 |      Get a component by this name
 |      :param name:
 |      :return:
 |  
 |  get_property(self, pname: str) -> Any
 |      Retrieve a node property
 |      :param pname:
 |      :return:
 |  
 |  remove_component(self, name: str) -> None
 |      Remove a component from the node (and network services and their interfaces)
 |      :param name:
 |      :return:
 |  
 |  remove_network_service(self, name: str) -> None
 |      Remove a network service from the node (and all its interfaces)
 |      :param name:
 |      :return:
 |  
 |  set_properties(self, **kwargs)
 |      Set multiple properties of the node
 |      :param kwargs:
 |      :return:
 |  
 |  set_property(self, pname: str, pval: Any)
 |      Set a node property
 |      :param pname:
 |      :param pval:
 |      :return:
 |  
 |  ----------------------------------------------------------------------
 |  Static methods defined here:
 |  
 |  list_properties() -> Tuple[str]
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  __abstractmethods__ = frozenset()
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from fim.user.model_element.ModelElement:
 |  
 |  __eq__(self, other)
 |      Return self==value.
 |  
 |  __hash__(self)
 |      Return hash(self).
 |  
 |  rename(self, new_name: str)
 |      Rename the model element in the model graph
 |      :param new_name:
 |      :return:
 |  
 |  unset_property(self, pname: str)
 |      Unset a property
 |      :param pname:
 |      :return:
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from fim.user.model_element.ModelElement:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
paul-ruth commented 3 years ago

Maybe this was added already. They asked about "ExperimentTopology". I know I tried it a while back and it didn't have help. Maybe this one is done.

ibaldin commented 3 years ago

This seems done. closing