Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing docstrings in facility_port module #347

Merged
merged 18 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove duplicate Node.delete() method (Issue [#321](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/321))

## Added
- Missing docstrings in facility_port module (Issue [#312](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/312))
- Missing docstrings in node module (Issue [#318](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/318))

## [1.6.4] - 2024-03-05
Expand Down
1 change: 1 addition & 0 deletions docs/source/facility_port.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ facility_port

.. autoclass:: fabrictestbed_extensions.fablib.facility_port.FacilityPort
:members:
:no-index:
:special-members: __str__
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ above. Currently, contents of the configuration file will override
values set using environment variables.


FABLib classes
FABLib modules
--------------

Most of FABLib's functionality comes wrapped in these classes:
FABLib functionality is made available in these modules:

.. toctree::
:maxdepth: 1
Expand Down
1 change: 0 additions & 1 deletion fabrictestbed_extensions/fablib/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

42 changes: 42 additions & 0 deletions fabrictestbed_extensions/fablib/facility_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@


class FacilityPort:
"""
A class for working with FABRIC facility ports.
"""

fim_interface = None
slice = None

Expand Down Expand Up @@ -75,14 +79,23 @@ def __str__(self):
return tabulate(table)

def toJson(self):
"""
Return a JSON representation of the facility port.
"""
return json.dumps(self.toDict(), indent=4)

def get_pretty_name_dict(self):
"""
Return a mapping used when rendering table headers.
"""
return {
"name": "Name",
}

def toDict(self, skip=[]):
"""
Return a Python `dict` representation of the facility port.
"""
return {"name": str(self.get_name())}

def get_template_context(self):
Expand All @@ -98,6 +111,9 @@ def render_template(self, input_string):
def show(
self, fields=None, output=None, quiet=False, colors=False, pretty_names=True
):
"""
Get a human-readable representation of the facility port.
"""
data = self.toDict(pretty_names=True)

# fields = ["Name",
Expand All @@ -120,20 +136,34 @@ def show(
return table

def get_fim_interface(self) -> FimNode:
"""
.. warning::
Not recommended for most users.

Gets the node's FABRIC Information Model (fim) object. This
method is used to access data at a lower level than FABlib.
"""
return self.fim_interface

def get_model(self) -> str:
"""
Get fablib model name for the facility port.
"""
return "Facility_Port"

def get_name(self) -> str:
"""
Gets the name of the FABRIC node.

:return: the name of the node
:rtype: String
"""
return self.get_fim_interface().name

def get_site(self) -> str:
"""
Gets the site associated with the facility port.
"""
return self.fim_interface.site

@staticmethod
Expand All @@ -144,6 +174,18 @@ def new_facility_port(
vlan: Union[str, list] = None,
bandwidth: int = 10,
):
"""
Create a new facility port.

You might want to :py:meth:`Slice.add_facility_port()`, in
most cases.

:param Slice: Slice associated with the facility port.
:param name: name of the facility port.
:param site: site associated with the facility port.
:param vlan: VLAN.
:param bandwidth: bandwidth to be used, in Gbps.
"""
if isinstance(vlan, list):
interfaces = []
index = 1
Expand Down
Loading