component

Methods to work with FABRIC components.

You normally would not create Component objects directly with a constructor call; they are created when you invoke fabrictestbed_extensions.fablib.node.Node.add_component(), like so:

node.add_component(model='NVME_P4510', name="nvme1")
node.add_component(model='NIC_Basic', name="nic1")
class fabrictestbed_extensions.fablib.component.Component(node=None, fim_component=None)[source]

Typically invoked when you add a component to a Node.

Note

Component constructer is not meant to be directly used.

Parameters:
  • node (Node) – the fablib node to build the component on

  • fim_component (FIMComponent) – the FIM component this object represents

static calculate_name(node=None, name=None)[source]

Not intended for API use

Return type:

str

configure(commands=[])[source]

Configure a component by executing a set of commands provided by the user or run any default commands.

Raises:

SliceStateError – if the node is not in Active state

configure_nvme(mount_point='')[source]

Configure the NVMe drive.

Note this works but may be reorganized.

Parameters:

mount_point (String) – The mount point in the filesystem. Default = “” later reassigned to /mnt/{linux device name}

Raises:

SliceStateError – if the node is not in Active state

delete()[source]

Remove the component from the slice/node.

generate_template_context(skip=None)[source]

Generate the base template context for this component.

Creates a dictionary context suitable for Jinja2 template rendering, including component attributes and an empty interfaces list.

Parameters:

skip (List[str]) – list of keys to exclude

Returns:

Template context dictionary with component attributes

Return type:

dict

get_details()[source]

Not intended for API use

Return type:

str

get_device_name()[source]

Not for API use

Return type:

str

get_disk()[source]

Gets the amount of disk space on this component.

Returns:

this component’s disk space

Return type:

int

get_error_message()[source]

Get error message for this component.

Returns:

reservation state

Return type:

String

get_fim()[source]

Gets the component’s FABRIC Information Model (fim) object.

This method is used to access data at a lower level than FABlib.

get_fim_component()[source]

Not recommended for most users.

Gets the FABRIC component this fablib component represents. This method is used to access data at a lower level than FABlib.

Returns:

the FABRIC component on this component

Return type:

FIMComponent

get_fim_model()[source]

Not for API use

Return type:

str

get_interface(name=None, network_name=None, refresh=False)[source]

Gets a particular interface attached to this component.

Accepts either the interface name or a network_name. If a network name is used, returns the interface connected to that network. If both name and network_name are provided, name takes precedence.

Parameters:
  • name (str) – the name of the interface to search for

  • network_name (str) – network name to search for

  • refresh (bool) – Refresh interface objects with latest FIM info

Returns:

the particular interface

Return type:

Interface

Raises:

Exception – if interface is not found

get_interfaces(include_subs=True, refresh=False, output='list')[source]

Gets the interfaces attached to this fablib component’s FABRIC component.

Results are cached. Use refresh=True to force reload from FIM.

Parameters:
  • include_subs (bool) – Flag indicating if sub interfaces should be included

  • refresh (bool) – Refresh the interface object with latest Fim info

  • output (str) – Specify how the return type is expected; Possible values: list or dict

Returns:

a list or dict of the interfaces on this component.

Return type:

Union[dict[str, Interface], list[Interface]]

get_model()[source]

Get FABlib model name for this component.

Returns:

FABlib model name

Return type:

String

get_node()[source]

Gets the fablib node this component is associated with.

Returns:

the node this component is on

Return type:

Node

get_numa_node()[source]

Get the Numa Node assigned to the device

Return type:

str

get_pci_addr()[source]

Get the PIC device ID for this component.

Returns:

PCI device ID

Return type:

String

static get_pretty_name_dict()[source]

Returns the mapping used when rendering table headers.

get_reservation_id()[source]

Get reservation ID for this component.

Returns:

reservation ID

Return type:

String

get_reservation_state()[source]

Get reservation state for this component.

Returns:

reservation state

Return type:

String

get_short_name()[source]

Gets the short name of the component.

get_site()[source]

Gets the name of the site this component’s node is on.

Returns:

the site name this node is on

Return type:

String

get_slice()[source]

Gets the fablib slice associated with this component’s node.

Returns:

the slice this component is on

Return type:

Slice

get_type()[source]

Not for API use

Gets the type of this component.

Returns:

the type of component

Return type:

str

get_unit()[source]

Get unit count for this component.

Returns:

unit

Return type:

int

list_interfaces(fields=None, output=None, quiet=False, filter_function=None, refresh=False)[source]

Lists all the interfaces in the component with their attributes.

There are several output options: “text”, “pandas”, and “json” that determine the format of the output that is returned and (optionally) displayed/printed.

output: ‘text’: string formatted with tabular

‘pandas’: pandas dataframe ‘json’: string in json format

fields: json output will include all available fields/columns.

Example: fields=[‘Name’,’MAC’]

filter_function: A lambda function to filter data by field values.

Example: filter_function=lambda s: s[‘Node’] == ‘Node1’

Parameters:
  • output (str) – output format

  • fields (List[str]) – list of fields (table columns) to show

  • quiet (bool) – True to specify printing/display

  • filter_function (lambda) – lambda function

  • refresh (bool) – Refresh the interface object with latest Fim info

Returns:

table in format specified by output parameter

Return type:

Object

static new_component(node=None, model=None, name=None, user_data={})[source]

Not intended for API use

Creates a new FIM component on the fablib node inputted.

Parameters:
  • node (Node) – the fablib node to build the component on

  • model (str) – the name of the component type to build

  • name (str) – the name of the new component

Returns:

the new fablib compoent

Return type:

Component

static new_storage(node, name, auto_mount=False)[source]

Not intended for API use

Creates a new FIM component on the fablib node inputted.

Parameters:
  • node (Node) – the fablib node to build the component on

  • name (str) – the name of the new component

  • auto_mount (bool) – True - mount the storage; False - do not mount

Returns:

the new fablib compoent

Return type:

Component

toDict(skip=None)[source]

Returns the component attributes as a dictionary.

Results are cached. Cache is invalidated when _invalidate_cache() is called.

Parameters:

skip (List[str]) – list of keys to exclude

Returns:

component attributes as dictionary

Return type:

dict

update(fim_component=None)[source]

Update the component with new FIM data.

Parameters:

fim_component (FimComponent) – The new FIM component data

class fabrictestbed_extensions.fablib.component.Component(node=None, fim_component=None)[source]

Typically invoked when you add a component to a Node.

Note

Component constructer is not meant to be directly used.

Parameters:
  • node (Node) – the fablib node to build the component on

  • fim_component (FIMComponent) – the FIM component this object represents

__str__()[source]

Creates a tabulated string describing the properties of the component.

Intended for printing component information.

Returns:

Tabulated string of component information

Return type:

String

static calculate_name(node=None, name=None)[source]

Not intended for API use

Return type:

str

configure(commands=[])[source]

Configure a component by executing a set of commands provided by the user or run any default commands.

Raises:

SliceStateError – if the node is not in Active state

configure_nvme(mount_point='')[source]

Configure the NVMe drive.

Note this works but may be reorganized.

Parameters:

mount_point (String) – The mount point in the filesystem. Default = “” later reassigned to /mnt/{linux device name}

Raises:

SliceStateError – if the node is not in Active state

delete()[source]

Remove the component from the slice/node.

generate_template_context(skip=None)[source]

Generate the base template context for this component.

Creates a dictionary context suitable for Jinja2 template rendering, including component attributes and an empty interfaces list.

Parameters:

skip (List[str]) – list of keys to exclude

Returns:

Template context dictionary with component attributes

Return type:

dict

get_details()[source]

Not intended for API use

Return type:

str

get_device_name()[source]

Not for API use

Return type:

str

get_disk()[source]

Gets the amount of disk space on this component.

Returns:

this component’s disk space

Return type:

int

get_error_message()[source]

Get error message for this component.

Returns:

reservation state

Return type:

String

get_fim()[source]

Gets the component’s FABRIC Information Model (fim) object.

This method is used to access data at a lower level than FABlib.

get_fim_component()[source]

Not recommended for most users.

Gets the FABRIC component this fablib component represents. This method is used to access data at a lower level than FABlib.

Returns:

the FABRIC component on this component

Return type:

FIMComponent

get_fim_model()[source]

Not for API use

Return type:

str

get_interface(name=None, network_name=None, refresh=False)[source]

Gets a particular interface attached to this component.

Accepts either the interface name or a network_name. If a network name is used, returns the interface connected to that network. If both name and network_name are provided, name takes precedence.

Parameters:
  • name (str) – the name of the interface to search for

  • network_name (str) – network name to search for

  • refresh (bool) – Refresh interface objects with latest FIM info

Returns:

the particular interface

Return type:

Interface

Raises:

Exception – if interface is not found

get_interfaces(include_subs=True, refresh=False, output='list')[source]

Gets the interfaces attached to this fablib component’s FABRIC component.

Results are cached. Use refresh=True to force reload from FIM.

Parameters:
  • include_subs (bool) – Flag indicating if sub interfaces should be included

  • refresh (bool) – Refresh the interface object with latest Fim info

  • output (str) – Specify how the return type is expected; Possible values: list or dict

Returns:

a list or dict of the interfaces on this component.

Return type:

Union[dict[str, Interface], list[Interface]]

get_model()[source]

Get FABlib model name for this component.

Returns:

FABlib model name

Return type:

String

get_node()[source]

Gets the fablib node this component is associated with.

Returns:

the node this component is on

Return type:

Node

get_numa_node()[source]

Get the Numa Node assigned to the device

Return type:

str

get_pci_addr()[source]

Get the PIC device ID for this component.

Returns:

PCI device ID

Return type:

String

static get_pretty_name_dict()[source]

Returns the mapping used when rendering table headers.

get_reservation_id()[source]

Get reservation ID for this component.

Returns:

reservation ID

Return type:

String

get_reservation_state()[source]

Get reservation state for this component.

Returns:

reservation state

Return type:

String

get_short_name()[source]

Gets the short name of the component.

get_site()[source]

Gets the name of the site this component’s node is on.

Returns:

the site name this node is on

Return type:

String

get_slice()[source]

Gets the fablib slice associated with this component’s node.

Returns:

the slice this component is on

Return type:

Slice

get_type()[source]

Not for API use

Gets the type of this component.

Returns:

the type of component

Return type:

str

get_unit()[source]

Get unit count for this component.

Returns:

unit

Return type:

int

list_interfaces(fields=None, output=None, quiet=False, filter_function=None, refresh=False)[source]

Lists all the interfaces in the component with their attributes.

There are several output options: “text”, “pandas”, and “json” that determine the format of the output that is returned and (optionally) displayed/printed.

output: ‘text’: string formatted with tabular

‘pandas’: pandas dataframe ‘json’: string in json format

fields: json output will include all available fields/columns.

Example: fields=[‘Name’,’MAC’]

filter_function: A lambda function to filter data by field values.

Example: filter_function=lambda s: s[‘Node’] == ‘Node1’

Parameters:
  • output (str) – output format

  • fields (List[str]) – list of fields (table columns) to show

  • quiet (bool) – True to specify printing/display

  • filter_function (lambda) – lambda function

  • refresh (bool) – Refresh the interface object with latest Fim info

Returns:

table in format specified by output parameter

Return type:

Object

static new_component(node=None, model=None, name=None, user_data={})[source]

Not intended for API use

Creates a new FIM component on the fablib node inputted.

Parameters:
  • node (Node) – the fablib node to build the component on

  • model (str) – the name of the component type to build

  • name (str) – the name of the new component

Returns:

the new fablib compoent

Return type:

Component

static new_storage(node, name, auto_mount=False)[source]

Not intended for API use

Creates a new FIM component on the fablib node inputted.

Parameters:
  • node (Node) – the fablib node to build the component on

  • name (str) – the name of the new component

  • auto_mount (bool) – True - mount the storage; False - do not mount

Returns:

the new fablib compoent

Return type:

Component

toDict(skip=None)[source]

Returns the component attributes as a dictionary.

Results are cached. Cache is invalidated when _invalidate_cache() is called.

Parameters:

skip (List[str]) – list of keys to exclude

Returns:

component attributes as dictionary

Return type:

dict

update(fim_component=None)[source]

Update the component with new FIM data.

Parameters:

fim_component (FimComponent) – The new FIM component data