node

Methods to work with FABRIC nodes.

You would add a node and operate on it like so:

from fabrictestbed_extensions.fablib.fablib import FablibManager

fablib = FablibManager()

slice = fablib.new_slice(name="MySlice")
node = slice.add_node(name="node1")
slice.submit();

node.execute('echo Hello, FABRIC from node `hostname -s`')

slice.delete()
class fabrictestbed_extensions.fablib.node.Node(slice, node, validate=False, raise_exception=False)[source]

Node constructor, usually invoked by Slice.add_node().

Parameters:
  • slice (Slice) – the fablib slice to have this node on

  • node (Node) – the FIM node that this Node represents

  • validate (bool) – Validate node can be allocated w.r.t available resources

  • raise_exception (bool) – Raise exception in case validation failes

add_component(model=None, name=None, user_data={})[source]

Creates a new FABRIC component using this fablib node. Example models include:

  • NIC_Basic: A single port 100 Gbps SR-IOV Virtual Function on a Mellanox ConnectX-6

  • NIC_ConnectX_5: A dual port 25 Gbps Mellanox ConnectX-5

  • NIC_ConnectX_6: A dual port 100 Gbps Mellanox ConnectX-6

  • NVME_P4510: NVMe Storage Device

  • GPU_TeslaT4: Tesla T4 GPU

  • GPU_RTX6000: RTX6000 GPU

  • GPU_A30: A30 GPU

  • GPU_A40: A40 GPU

  • FPGA_Xilinx_U280: Xilinx U280 FPGA card

Note

Some component types (e.g. NVME_P4510, GPUs, FPGAs) require specific project-level permissions. If your project lacks the necessary permissions, the slice submission will fail with an error from the orchestrator.

Parameters:
  • model (String) – the name of the component model to add

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

Returns:

the new component

Return type:

Component

add_fabnet(name='FABNET', net_type='IPv4', nic_type='NIC_Basic', routes=None, subnet=None)[source]

Add a simple layer 3 network to this node.

Parameters:
  • name – a name for the network. Default is "FABNET".

  • net_type – Network type, "IPv4" or "IPv6".

  • nic_type – a NIC type. Default is "NIC_Basic".

  • routes – a list of routes to add. Default is None.

  • subnet (ipaddress.ip_network) – Request a specific subnet for FabNetv4, FabNetv6 or FabNetv6Ext services. It’s ignored for any other services.

add_post_boot_execute(command)[source]

Execute a command on the node after boot.

Parameters:

command (str) – command to be executed on the node.

add_post_boot_upload_directory(local_directory_path, remote_directory_path='.')[source]

Upload a directory to the node after boot.

Parameters:
  • local_directory_path (str) – local directory.

  • remote_directory_path (str) – directory on the node.

add_post_boot_upload_file(local_file_path, remote_file_path='.')[source]

Upload a file to the node after boot.

Parameters:
  • local_file_path (str) – path to file on local filesystem.

  • remote_file_path (str) – path to file on the node.

add_post_update_command(command)[source]

Run a command after boot.

add_public_key(*, sliver_key_name=None, email=None, sliver_public_key=None)[source]

Add public key to a node; - Adds user’s portal public key identified by sliver_key_name to the node - Adds portal public key identified by sliver_key_name for a user identified by email to the node - Add public key from the sliver_public_key to the node

Parameters:
  • sliver_key_name (str) – Sliver Key Name on the Portal

  • email (str) – Email

  • sliver_public_key (str) – Public sliver key

:raises Exception in case of errors

add_route(subnet, next_hop)[source]

Add a route.

Parameters:

subnet (Union[IPv4Network, IPv6Network]) – an IPv4 or IPv6 address.

:type subnet:IPv4Network or IPv6Network.

Parameters:

next_hop (IPv4Address or IPv6Address or NetworkService.) – a gateway address (IPv4Address or IPv6Address) or a NetworkService.

add_storage(name, auto_mount=False)[source]

Creates a new FABRIC NAS Storage component and attaches it to the Node.

The auto_mount flag is passed to the orchestrator via FIM. If the orchestrator does not honour the flag, the storage volume will need to be mounted manually after the slice reaches StableOK.

For CephFS persistent storage that is automatically mounted during post-boot configuration, use enable_storage() instead.

Parameters:
  • name (str) – Name of the Storage volume created for the project outside the scope of the Slice

  • auto_mount (bool) – Request the orchestrator to mount the storage volume automatically.

Return type:

Component

add_vlan_os_interface(os_iface=None, vlan=None, ip=None, cidr=None, mtu=None, interface=None, persistent=None)[source]

Add VLAN tagged interface for a given interface and set IP address on it

Parameters:
  • os_iface (String) – Interface name as seen by the OS such as eth1 etc.

  • vlan (String) – Vlan tag

  • ip (String) – IP address to be assigned to the tagged interface

  • cidr (str) – CIDR associated with IP address

  • mtu (String) – MTU size

  • interface (Interface) – Interface for which tagged interface has to be added

  • persistent (bool) – Override persistent config setting

clear_all_ifaces()[source]

Flush all interfaces and delete VLAN os interfaces

close_ssh()[source]

Close cached SSH connections to this node.

Releases the cached bastion and node SSH connections. Safe to call multiple times. New connections will be created automatically on the next execute/upload/download call.

config(log_dir='.', refresh=False)[source]

Run configuration tasks for this node.

Parameters:

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

Note

Use this method in order to re-apply configuration to a rebooted node. Normally this method is invoked by Slice.submit() or Slice.modify().

Configuration tasks include:

  • Setting hostname.

  • Configuring interfaces.

  • Configuring routes.

  • Running post-boot tasks added by add_post_boot_execute(), add_post_boot_upload_file(), and add_post_boot_upload_directory().

  • Running post-update commands added by add_post_update_command().

config_routes()[source]

Warning

This method is for fablib internal use, and will be made private in the future.

delete()[source]

Remove the node from the slice. All components and interfaces associated with the Node are removed from the Slice.

download_directory(local_directory_path, remote_directory_path, retry=3, retry_interval=10)[source]

Downloads a directory from remote location on the node. Makes a gzipped tarball of a directory and downloads it from a node. Then unzips and tars the directory at the local_directory_path

Parameters:
  • local_directory_path (str) – the path to the directory to upload

  • remote_directory_path (str) – the destination path of the directory on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Raises:
download_directory_thread(local_directory_path, remote_directory_path, retry=3, retry_interval=10)[source]

Creates a thread that calls node.download_directory. Results from the thread can be retrieved with by calling thread.result()

Parameters:
  • local_directory_path (str) – the path to the directory to upload

  • remote_directory_path (str) – the destination path of the directory on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Raises:

Exception – if management IP is invalid

download_file(local_file_path, remote_file_path, retry=3, retry_interval=10)[source]

Download a remote file from the node to a local destination.

Parameters:
  • local_file_path (str) – the destination path for the remote file

  • remote_file_path (str) – the path to the remote file to download

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP upon failure

Raises:

RuntimeError – if no_ssh mode is enabled

download_file_thread(local_file_path, remote_file_path, retry=3, retry_interval=10)[source]

Creates a thread that calls node.download_file(). Results from the thread can be retrieved with by calling thread.result()

Parameters:
  • local_file_path (str) – the destination path for the remote file

  • remote_file_path (str) – the path to the remote file to download

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP upon failure

Returns:

a thread that called node.download_file()

Return type:

Thread

Raises:

Exception – if management IP is invalid

enable_storage(cluster=None)[source]

Enable CephFS storage on this node.

Adds a FABNetv4 network (if not already present) and marks the node so that Slice.post_boot_config() will automatically generate credentials, upload them, and mount the CephFS filesystem.

Parameters:

cluster (str) – Ceph cluster name (e.g. "europe"). When None the first available cluster is auto-discovered at post-boot time.

execute(command, retry=3, retry_interval=10, username=None, private_key_file=None, private_key_passphrase=None, quiet=False, read_timeout=10, timeout=None, output_file=None, display=True)[source]

Runs one or more commands on the FABRIC node using SSH, supporting both standard and interactive execution.

Parameters:
  • command (str | list[str] | list[tuple[str, str, int]]) – Commands to execute. Can be: - A string (single command) - A list of strings (multiple commands executed sequentially) - A list of (command, prompt, timeout) tuples (interactive commands with expected prompts)

  • retry (int) – Number of retry attempts in case of failure.

  • retry_interval (int) – Time interval (seconds) between retries.

  • username (str) – SSH username.

  • private_key_file (str) – Path to the private key file.

  • private_key_passphrase (str) – Passphrase for private key.

  • quiet (bool) – Suppress output if True.

  • prompt_changes (bool) – Whether to allow changing prompts dynamically in interactive mode.

  • read_timeout (int) – Time to wait before reading stdout/stderr.

  • timeout (int) – Command timeout in seconds.

  • output_file (str) – File path for output logging.

  • display (bool) – Show interactive execution output if True.

Returns:

A tuple (stdout, stderr).

Return type:

Tuple[str, str]

Raises:
execute_thread(command, retry=3, retry_interval=10, username=None, private_key_file=None, private_key_passphrase=None, output_file=None)[source]

Creates a thread that calls node.execute(). Results (i.e. stdout, stderr) from the thread can be retrieved with by calling thread.result()

Parameters:
  • command (str) – the command to run

  • retry (int) – the number of times to retry SSH upon failure

  • retry_interval (int) – the number of seconds to wait before retrying SSH upon failure

  • username (str) – username

  • private_key_file (str) – path to private key file

  • private_key_passphrase (str) – pass phrase

  • output_file (List[str]) – path to a file where the stdout/stderr will be written. None for no file output

Return type:

Thread

Returns:

a thread that called node.execute()

Raises:

Exception – if management IP is invalid

flush_all_os_interfaces()[source]

Flushes the configuration of all dataplane interfaces in the node.

flush_os_interface(os_iface, persistent=None)[source]

Flush the configuration of an interface in the node

Parameters:
  • os_iface (String) – the name of the interface to flush

  • persistent (bool) – if True, also remove persistent config (nmcli/netplan)

generate_template_context(skip=None)[source]

Build a Jinja2 template context dict for this node.

get_component(name, refresh=False)[source]

Retrieve a component associated with this node.

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

Parameters:
  • name (str) – Name of the component to retrieve

  • refresh (bool) – Whether to refresh the component from the latest FIM data

Returns:

The requested component

Return type:

Component

Raises:

Exception – If the component is not found

get_components(refresh=False)[source]

Gets a list of components associated with this node.

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

Parameters:

refresh (bool) – Refresh the component objects with latest FIM info

Returns:

a list of components on this node

Return type:

List[Component]

get_cores()[source]

Gets the number of cores on the FABRIC node.

Returns:

the number of cores on the node

Return type:

int

get_cpu_info()[source]

Get CPU Information for the Node and the host on which the VM is running

Return type:

dict

Returns:

cpu info dict

get_dataplane_os_interfaces()[source]

Gets a list of all the dataplane interface names used by the node’s operating system.

Returns:

interface names

Return type:

List[String]

get_disk()[source]

Gets the amount of disk space on the FABRIC node.

Returns:

the amount of disk space on the node

Return type:

int

get_fim()[source]

Get FABRIC Information Model (fim) object for the node.

get_fim_node()[source]

Get FABRIC Information Model (fim) node object.

Alias for get_fim() for backward compatibility.

get_host()[source]

Gets the hostname on the FABRIC node.

Returns:

the hostname on the node

Return type:

String

get_image()[source]

Gets the image reference on the FABRIC node.

Returns:

the image reference on the node

Return type:

String

get_image_type()[source]

Gets the image type on the FABRIC node.

Returns:

the image type on the node

Return type:

String

get_instance_name()[source]

Gets the instance name of the FABRIC node.

Returns:

the instance name of the node

Return type:

String

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

Gets a particular interface associated with a FABRIC node.

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) – interface name to search for

  • network_name (str) – network name to search for

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

  • raise_exception (bool) – if True, raise ResourceNotFoundError when the interface is not found; if False, return None. When None (default), falls back to the global FablibManager.raise_on_not_found setting.

Returns:

an interface on the node or None

Return type:

Optional[Interface]

Raises:

ResourceNotFoundError – if the interface is not found and raising is enabled

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

Gets a list of the interfaces associated with the FABRIC node.

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 objects with latest FIM info

  • output (str) – Return type - ‘list’ or ‘dict’

Returns:

interfaces on the node

Return type:

Union[Dict[str, Interface], List[Interface]]

get_ip_addrs()[source]

Get a list of ip address info from the node.

get_ip_routes()[source]

Get a list of routes from the node.

get_management_ip()[source]

Gets the management IP of the node (IPv6).

First attempts to read from the FIM topology. If the topology does not have the IP populated, falls back to the sliver info returned by the orchestrator.

Results are cached for performance.

Returns:

management IP

Return type:

String

get_management_os_interface()[source]

Gets the name of the management interface used by the node’s operating system, based on the default route.

Returns:

Name of the management interface or None if not found

Return type:

Optional[str]

get_networks(refresh=False)[source]

Get a list of networks attached to the node. :type refresh: bool :param refresh: Refresh the object with latest Fim info :type refresh: bool

static get_node(slice=None, node=None)[source]

Returns a new fablib node using existing FABRIC resources.

Note:

Not intended for API call.

Parameters:
  • slice (Slice) – the fablib slice storing the existing node

  • node (Node) – the FIM node stored in this fablib node

Returns:

a new fablib node storing resources

Return type:

Node

get_numa_info()[source]

Get Numa Information for the Node and the host on which the VM is running

Return type:

dict

Returns:

numa info dict

get_paramiko_key(private_key_file=None, get_private_key_passphrase=None)[source]

Get SSH pubkey, for internal use.

Returns:

an SSH pubkey.

Return type:

paramiko.PKey

get_post_update_commands()[source]

Get the list of commands that are to be run after boot.

static get_pretty_name_dict()[source]

Return mappings from non-pretty names to pretty names.

Pretty names are in table headers.

get_private_key()[source]

Gets the private key on the fablib node.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the private key on the node

Return type:

String

get_private_key_file()[source]

Gets the private key file path on the fablib slice.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the private key path

Return type:

String

get_private_key_passphrase()[source]

Gets the private key passphrase on the FABLIB slice.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the private key passphrase

Return type:

String

get_public_key()[source]

Gets the public key on fablib node.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the public key on the node

Return type:

String

get_public_key_file()[source]

Gets the public key file path on the fablib node.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the public key path

Return type:

String

get_ram()[source]

Gets the amount of RAM on the FABRIC node.

Returns:

the amount of RAM on the node

Return type:

int

get_requested_cores()[source]

Gets the requested number of cores on the FABRIC node.

Returns:

the requested number of cores on the node

Return type:

int

get_requested_disk()[source]

Gets the amount of disk space on the FABRIC node.

Returns:

the amount of disk space on the node

Return type:

int

get_requested_ram()[source]

Gets the requested amount of RAM on the FABRIC node.

Returns:

the requested amount of RAM on the node

Return type:

int

get_routes()[source]

Warning

This method is for fablib internal use, and will be made private in the future.

get_site()[source]

Gets the site this node is on.

Results are cached for performance.

Returns:

the site this node is on

Return type:

String

get_slice()[source]

Gets the fablib slice associated with this node.

Returns:

the fablib slice on this node

Return type:

Slice

get_sliver()[source]

Gets the node SM sliver.

Note:

Not intended as API call.

Returns:

SM sliver for the node

Return type:

Sliver

get_ssh_command()[source]

Gets an SSH command used to access this node from a terminal.

Returns:

the SSH command to access this node

Return type:

str

get_storage(name)[source]

Gets a particular storage associated with this node.

Parameters:

name (String) – the name of the storage

Raises:

Exception – if storage not found by name

Returns:

the storage on the FABRIC node

Return type:

Component

get_storage_cluster()[source]

Return the Ceph cluster name associated with this node, or None if none was specified.

Returns:

cluster name or None

Return type:

str or None

get_type()[source]

Gets the type of the network services.

Results are cached for performance.

Returns:

network service types

Return type:

NodeType

get_username()[source]

Gets the username on this fablib node.

Returns:

the username on this node

Return type:

String

has_storage()[source]

Check whether CephFS storage is enabled on this node.

Returns:

True if storage was enabled via enable_storage().

Return type:

bool

init_fablib_data()[source]

Initialize fablib data. Called by new_node().

ip_addr_add(addr, subnet, interface, persistent=None)[source]

Add an IP to an interface on the node.

Parameters:
  • addr (IPv4Address or IPv6Address) – IP address

  • subnet (IPv4Network or IPv6Network) – subnet.

  • interface (Interface) – the FABlib interface.

  • persistent (bool) – Override persistent config setting

ip_addr_del(addr, subnet, interface)[source]

Delete an IP to an interface on the node.

Parameters:
  • addr (IPv4Address or IPv6Address) – IP address

  • subnet (IPv4Network or IPv6Network) – subnet.

  • interface (Interface) – the FABlib interface.

ip_addr_list(output='json', update=False)[source]

Return the list of IP addresses assciated with this node.

Parameters:
  • output – Output format; "json" by default.

  • update – Setting this to True will force-update the cached list of IP addresses; default is False.

Returns:

When output is set to "json" (which is the default), the result of running ip -j[son] addr list, converted to a Python object. Otherwise the result of ip addr list.

Bring down a link on an interface on the node.

Parameters:
  • subnet (IPv4Network or IPv6Network) – subnet.

  • interface (Interface) – the FABlib interface.

Bring up a link on an interface on the node.

Parameters:
  • subnet (IPv4Network or IPv6Network) – subnet.

  • interface (Interface) – the FABlib interface.

ip_route_add(subnet, gateway, interface=None, persistent=None)[source]

Add a route on the node.

Parameters:
  • subnet (IPv4Network or IPv6Network) – The destination subnet

  • gateway (IPv4Address or IPv6Address) – The next hop gateway.

  • interface (Interface) – Optional interface for nmcli connection lookup

  • persistent (bool) – Override persistent config setting

ip_route_del(subnet, gateway)[source]

Delete a route on the node.

Parameters:
  • subnet (IPv4Network or IPv6Network) – The destination subnet

  • gateway (IPv4Address or IPv6Address) – The next hop gateway.

is_instantiated()[source]

Returns True if the node has been instantiated.

list_components(fields=None, output=None, quiet=False, filter_function=None, pretty_names=True, refresh=False)[source]

Lists all the components in the node 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.

Parameters:
  • output (str) –

    output format. Output can be one of:

    • "text": string formatted with tabular

    • "pandas": pandas dataframe

    • "json": string in json format

  • fields (List[str]) – list of fields (table columns) to show. JSON output will include all available fields/columns.

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

  • filter_function (lambda) – A lambda function to filter data by field values.

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

Returns:

table in format specified by output parameter

Return type:

Object

Here’s an example of fields:

fields=['Name','Model']

Here’s an example of filter_function:

filter_function=lambda s: s['Model'] == 'NIC_Basic'
list_interfaces(fields=None, output=None, quiet=False, filter_function=None, pretty_names=True, refresh=False)[source]

Lists all the interfaces in the node 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.

Parameters:
  • output (str) –

    Output format. Options are:

    • "text": string formatted with tabular

    • "pandas": pandas dataframe

    • "json": string in json format

  • fields (List[str]) – List of fields (table columns) to show. JSON output will include all available fields/columns.

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

  • filter_function (lambda) – A lambda function to filter data by field values.

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

Returns:

table in format specified by output parameter

Return type:

Object

Example of fields:

fields=['Name','MAC']

Example of filter_function:

filter_function=lambda s: s['Node'] == 'Node1'
list_networks(fields=None, output=None, quiet=False, filter_function=None, pretty_names=True, refresh=False)[source]

Lists all the networks attached to the nodes 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.

Parameters:
  • output (str) –

    Output format. Options are:

    • "text": string formatted with tabular

    • "pandas": pandas dataframe

    • "json": string in JSON format

  • fields (List[str]) – List of fields (table columns) to show. JSON output will include all available fields/columns.

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

  • filter_function (lambda) – A lambda function to filter data by field values.

  • pretty_names (bool) – Use “nicer” names in column headers. Default is True.

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

Returns:

table in format specified by output parameter

Return type:

Object

Example of fields:

fields=['Name','Type']

Example of filter_function:

filter_function=lambda s: s['Type'] == 'FABNetv4'
network_manager_start()[source]

(re)Start network manager on the node.

network_manager_stop()[source]

Stop network manager on the node.

static new_node(slice=None, name=None, site=None, avoid=None, validate=False, raise_exception=False)[source]

Creates a new FABRIC node on the slice.

Not intended for API use. Use slice.add_node() instead.

Parameters:
  • slice (SliceV2) – the fablib slice to build the new node on

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

  • site (str) – the name of the site to build the node on

  • avoid (List[str]) – a list of site names to avoid

  • validate (bool) – Validate node can be allocated w.r.t available resources

  • raise_exception (bool) – Raise exception if validation fails

Returns:

a new Node

Return type:

Node

numa_tune()[source]

Pin the memory for the VM to the numa node associated with the components

os_reboot()[source]

Request Openstack to reboot the VM. NOTE: This is not same as rebooting the VM via reboot or init 6 command. Instead this is like openstack server reboot.

pin_cpu(component_name, cpu_range_to_pin=None)[source]

Pin the cpus for the VM to the numa node associated with the component.

Parameters:
  • component_name (str) – Component Name

  • cpu_range_to_pin (str) – range of the cpus to pin; example: 0-1 or 0

ping_test(dst_ip)[source]

Test a ping from the node to a destination IP

Parameters:

dst_ip (String) – destination IP String.

Return type:

bool

poa(operation, vcpu_cpu_map=None, node_set=None, keys=None, bdf=None)[source]

Perform operation action on a VM; an action which is triggered by CF via the Aggregate

Parameters:
  • operation (str) – operation to be performed

  • vcpu_cpu_map (List[Dict[str, str]]) – map virtual cpu to host cpu map

  • node_set (List[str]) – list of numa nodes

  • keys (List[Dict[str, str]]) – list of ssh keys

  • bdf (List[str]) – list of PCI Ids

Raises:

Exception – in case of failure

Return type:

Union[Dict, str]

Returns:

State of POA or Dictionary containing the info, in case of INFO POAs

post_boot_tasks()[source]

Get the list of tasks to be performed on this node after boot.

remove_all_vlan_os_interfaces()[source]

Delete all VLAN os interfaces

remove_public_key(*, sliver_key_name=None, email=None, sliver_public_key=None)[source]

Remove public key to a node; - Remove user’s portal public key identified by sliver_key_name to the node - Remove portal public key identified by sliver_key_name for a user identified by email to the node - Remove public key from the sliver_public_key to the node

Parameters:
  • sliver_key_name (str) – Sliver Key Name on the Portal

  • email (str) – Email

  • sliver_public_key (str) – Public sliver key

:raises Exception in case of errors

remove_vlan_os_interface(os_iface=None, persistent=None)[source]

Remove one VLAN OS interface

Parameters:
  • os_iface (String) – the name of the VLAN interface to remove

  • persistent (bool) – Override persistent config setting

rescan_pci(component_name=None)[source]

Rescan PCI devices for a specific component or all components.

Parameters:

component_name (str) – Name of the component to rescan. If None, rescans all components.

Raises:

RuntimeError – If no PCI devices are found or if the rescan operation fails.

run_post_boot_tasks(log_dir='.')[source]

Run post-boot tasks. Called by config().

Post-boot tasks are list of commands associated with post_boot_tasks in fablib data.

run_post_update_commands(log_dir='.')[source]

Run post-update commands. Called by config().

Post-update commands are list of commands associated with post_update_commands in fablib data.

run_update_commands()[source]

Returns True if run_update_commands flag is set.

set_capacities(cores=2, ram=2, disk=10)[source]

Sets the capacities of the FABRIC node.

Parameters:
  • cores (int) – the number of cores to set on this node

  • ram (int) – the amount of RAM to set on this node

  • disk (int) – the amount of disk space to set on this node

set_host(host_name=None)[source]

Sets the hostname of this fablib node on the FABRIC node.

Parameters:

host_name (String) – the hostname. example: host_name=’renc-w2.fabric-testbed.net’

set_image(image, username=None, image_type='qcow2')[source]

Sets the image information of this fablib node on the FABRIC node.

Parameters:
  • image (String) – the image reference to set

  • username (String) – the username of this fablib node. Currently unused.

  • image_type (String) – the image type to set

set_instance_type(instance_type)[source]

Sets the instance type of this fablib node on the FABRIC node.

Parameters:

instance_type (String) – the name of the instance type to set

set_instantiated(instantiated=True)[source]

Mark node as instantiated. Called by config().

set_ip_os_interface(os_iface=None, vlan=None, ip=None, cidr=None, mtu=None, persistent=None)[source]

Configure IP Address on network interface as seen inside the VM :type os_iface: str :param os_iface: Interface name as seen by the OS such as eth1 etc. :type os_iface: String

Parameters:
  • vlan (String) – Vlan tag

  • ip (String) – IP address to be assigned to the tagged interface

  • cidr (str) – CIDR associated with IP address

  • mtu (String) – MTU size

  • persistent (bool) – Override persistent config setting

NOTE: This does not add the IP information in the fablib_data

set_run_update_commands(run_update_commands=True)[source]

Set run_update_commands flag.

set_site(site)[source]

Sets the site of this fablib node on FABRIC.

Parameters:

site – the site

set_username(username=None)[source]

Sets this fablib node’s username

Note:

Not intended as an API call.

Parameters:

username (str) – Optional username parameter. The username likely should be picked to match the image type.

show(fields=None, output=None, quiet=False, colors=False, pretty_names=True)[source]

Show a table containing the current node attributes.

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

Parameters:
  • output (str) –

    output format. Options are:

    • "text": string formatted with tabular

    • "pandas": pandas dataframe

    • "json": string in json format

  • fields (List[str]) – List of fields to show. JSON output will include all available fields.

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

  • colors (bool) – True to specify state colors for pandas output

Returns:

table in format specified by output parameter

Return type:

Object

Here’s an example of fields:

fields=['Name','State']
test_ssh()[source]

Test whether SSH is functional on the node.

Returns:

true if SSH is working, false otherwise (always False if no_ssh)

Return type:

bool

toDict(skip=None)[source]

Returns the node 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:

node attributes as dictionary

Return type:

dict

un_manage_interface(interface)[source]

Mark an interface unmanaged by Network Manager.

When using the nmcli backend, this is a no-op because NM manages the interface persistently. Only applies to legacy (ip) backend.

Parameters:

interface (Interface) – the FABlib interface.

update(fim_node)[source]

Update this node with a new FIM node and refresh components/interfaces.

upload_directory(local_directory_path, remote_directory_path, retry=3, retry_interval=10)[source]

Upload a directory to remote location on the node.

Makes a gzipped tarball of a directory and uploads it to a node. Then unzips and untars the directory at the remote_directory_path.

Parameters:
  • local_directory_path (str) – the path to the directory to upload

  • remote_directory_path (str) – the destination path of the directory on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Raises:
upload_directory_thread(local_directory_path, remote_directory_path, retry=3, retry_interval=10)[source]

Creates a thread that calls Node.upload_directory().

Results from the thread can be retrieved with by calling thread.result().

Parameters:
  • local_directory_path (str) – the path to the directory to upload

  • remote_directory_path (str) – the destination path of the directory on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Returns:

a thread that called node.upload_directory()

Return type:

Thread

Raises:

Exception – if management IP is invalid

upload_file(local_file_path, remote_file_path='.', retry=3, retry_interval=10)[source]

Upload a local file to a remote location on the node.

Parameters:
  • local_file_path (str) – the path to the file to upload

  • remote_file_path (str) – the destination path of the file on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Raises:
upload_file_thread(local_file_path, remote_file_path='.', retry=3, retry_interval=10)[source]

Creates a thread that calls node.upload_file().

Results from the thread can be retrieved with by calling thread.result().

Parameters:
  • local_file_path (str) – the path to the file to upload

  • remote_file_path (str) – the destination path of the file on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Returns:

a thread that called node.execute()

Return type:

Thread

Raises:

Exception – if management IP is invalid

validIPAddress(IP)[source]

Checks if the IP string is a valid IP address.

Parameters:

IP (String) – the IP string to check

Returns:

the type of IP address the IP string is, or ‘Invalid’

Return type:

String

class fabrictestbed_extensions.fablib.node.Node(slice, node, validate=False, raise_exception=False)[source]

Node constructor, usually invoked by Slice.add_node().

Parameters:
  • slice (Slice) – the fablib slice to have this node on

  • node (Node) – the FIM node that this Node represents

  • validate (bool) – Validate node can be allocated w.r.t available resources

  • raise_exception (bool) – Raise exception in case validation failes

__str__()[source]

Creates a tabulated string describing the properties of the node.

Intended for printing node information.

Returns:

Tabulated string of node information

Return type:

String

add_component(model=None, name=None, user_data={})[source]

Creates a new FABRIC component using this fablib node. Example models include:

  • NIC_Basic: A single port 100 Gbps SR-IOV Virtual Function on a Mellanox ConnectX-6

  • NIC_ConnectX_5: A dual port 25 Gbps Mellanox ConnectX-5

  • NIC_ConnectX_6: A dual port 100 Gbps Mellanox ConnectX-6

  • NVME_P4510: NVMe Storage Device

  • GPU_TeslaT4: Tesla T4 GPU

  • GPU_RTX6000: RTX6000 GPU

  • GPU_A30: A30 GPU

  • GPU_A40: A40 GPU

  • FPGA_Xilinx_U280: Xilinx U280 FPGA card

Note

Some component types (e.g. NVME_P4510, GPUs, FPGAs) require specific project-level permissions. If your project lacks the necessary permissions, the slice submission will fail with an error from the orchestrator.

Parameters:
  • model (String) – the name of the component model to add

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

Returns:

the new component

Return type:

Component

add_fabnet(name='FABNET', net_type='IPv4', nic_type='NIC_Basic', routes=None, subnet=None)[source]

Add a simple layer 3 network to this node.

Parameters:
  • name – a name for the network. Default is "FABNET".

  • net_type – Network type, "IPv4" or "IPv6".

  • nic_type – a NIC type. Default is "NIC_Basic".

  • routes – a list of routes to add. Default is None.

  • subnet (ipaddress.ip_network) – Request a specific subnet for FabNetv4, FabNetv6 or FabNetv6Ext services. It’s ignored for any other services.

add_post_boot_execute(command)[source]

Execute a command on the node after boot.

Parameters:

command (str) – command to be executed on the node.

add_post_boot_upload_directory(local_directory_path, remote_directory_path='.')[source]

Upload a directory to the node after boot.

Parameters:
  • local_directory_path (str) – local directory.

  • remote_directory_path (str) – directory on the node.

add_post_boot_upload_file(local_file_path, remote_file_path='.')[source]

Upload a file to the node after boot.

Parameters:
  • local_file_path (str) – path to file on local filesystem.

  • remote_file_path (str) – path to file on the node.

add_post_update_command(command)[source]

Run a command after boot.

add_public_key(*, sliver_key_name=None, email=None, sliver_public_key=None)[source]

Add public key to a node; - Adds user’s portal public key identified by sliver_key_name to the node - Adds portal public key identified by sliver_key_name for a user identified by email to the node - Add public key from the sliver_public_key to the node

Parameters:
  • sliver_key_name (str) – Sliver Key Name on the Portal

  • email (str) – Email

  • sliver_public_key (str) – Public sliver key

:raises Exception in case of errors

add_route(subnet, next_hop)[source]

Add a route.

Parameters:

subnet (Union[IPv4Network, IPv6Network]) – an IPv4 or IPv6 address.

:type subnet:IPv4Network or IPv6Network.

Parameters:

next_hop (IPv4Address or IPv6Address or NetworkService.) – a gateway address (IPv4Address or IPv6Address) or a NetworkService.

add_storage(name, auto_mount=False)[source]

Creates a new FABRIC NAS Storage component and attaches it to the Node.

The auto_mount flag is passed to the orchestrator via FIM. If the orchestrator does not honour the flag, the storage volume will need to be mounted manually after the slice reaches StableOK.

For CephFS persistent storage that is automatically mounted during post-boot configuration, use enable_storage() instead.

Parameters:
  • name (str) – Name of the Storage volume created for the project outside the scope of the Slice

  • auto_mount (bool) – Request the orchestrator to mount the storage volume automatically.

Return type:

Component

add_vlan_os_interface(os_iface=None, vlan=None, ip=None, cidr=None, mtu=None, interface=None, persistent=None)[source]

Add VLAN tagged interface for a given interface and set IP address on it

Parameters:
  • os_iface (String) – Interface name as seen by the OS such as eth1 etc.

  • vlan (String) – Vlan tag

  • ip (String) – IP address to be assigned to the tagged interface

  • cidr (str) – CIDR associated with IP address

  • mtu (String) – MTU size

  • interface (Interface) – Interface for which tagged interface has to be added

  • persistent (bool) – Override persistent config setting

clear_all_ifaces()[source]

Flush all interfaces and delete VLAN os interfaces

close_ssh()[source]

Close cached SSH connections to this node.

Releases the cached bastion and node SSH connections. Safe to call multiple times. New connections will be created automatically on the next execute/upload/download call.

config(log_dir='.', refresh=False)[source]

Run configuration tasks for this node.

Parameters:

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

Note

Use this method in order to re-apply configuration to a rebooted node. Normally this method is invoked by Slice.submit() or Slice.modify().

Configuration tasks include:

  • Setting hostname.

  • Configuring interfaces.

  • Configuring routes.

  • Running post-boot tasks added by add_post_boot_execute(), add_post_boot_upload_file(), and add_post_boot_upload_directory().

  • Running post-update commands added by add_post_update_command().

config_routes()[source]

Warning

This method is for fablib internal use, and will be made private in the future.

delete()[source]

Remove the node from the slice. All components and interfaces associated with the Node are removed from the Slice.

download_directory(local_directory_path, remote_directory_path, retry=3, retry_interval=10)[source]

Downloads a directory from remote location on the node. Makes a gzipped tarball of a directory and downloads it from a node. Then unzips and tars the directory at the local_directory_path

Parameters:
  • local_directory_path (str) – the path to the directory to upload

  • remote_directory_path (str) – the destination path of the directory on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Raises:
download_directory_thread(local_directory_path, remote_directory_path, retry=3, retry_interval=10)[source]

Creates a thread that calls node.download_directory. Results from the thread can be retrieved with by calling thread.result()

Parameters:
  • local_directory_path (str) – the path to the directory to upload

  • remote_directory_path (str) – the destination path of the directory on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Raises:

Exception – if management IP is invalid

download_file(local_file_path, remote_file_path, retry=3, retry_interval=10)[source]

Download a remote file from the node to a local destination.

Parameters:
  • local_file_path (str) – the destination path for the remote file

  • remote_file_path (str) – the path to the remote file to download

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP upon failure

Raises:

RuntimeError – if no_ssh mode is enabled

download_file_thread(local_file_path, remote_file_path, retry=3, retry_interval=10)[source]

Creates a thread that calls node.download_file(). Results from the thread can be retrieved with by calling thread.result()

Parameters:
  • local_file_path (str) – the destination path for the remote file

  • remote_file_path (str) – the path to the remote file to download

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP upon failure

Returns:

a thread that called node.download_file()

Return type:

Thread

Raises:

Exception – if management IP is invalid

enable_storage(cluster=None)[source]

Enable CephFS storage on this node.

Adds a FABNetv4 network (if not already present) and marks the node so that Slice.post_boot_config() will automatically generate credentials, upload them, and mount the CephFS filesystem.

Parameters:

cluster (str) – Ceph cluster name (e.g. "europe"). When None the first available cluster is auto-discovered at post-boot time.

execute(command, retry=3, retry_interval=10, username=None, private_key_file=None, private_key_passphrase=None, quiet=False, read_timeout=10, timeout=None, output_file=None, display=True)[source]

Runs one or more commands on the FABRIC node using SSH, supporting both standard and interactive execution.

Parameters:
  • command (str | list[str] | list[tuple[str, str, int]]) – Commands to execute. Can be: - A string (single command) - A list of strings (multiple commands executed sequentially) - A list of (command, prompt, timeout) tuples (interactive commands with expected prompts)

  • retry (int) – Number of retry attempts in case of failure.

  • retry_interval (int) – Time interval (seconds) between retries.

  • username (str) – SSH username.

  • private_key_file (str) – Path to the private key file.

  • private_key_passphrase (str) – Passphrase for private key.

  • quiet (bool) – Suppress output if True.

  • prompt_changes (bool) – Whether to allow changing prompts dynamically in interactive mode.

  • read_timeout (int) – Time to wait before reading stdout/stderr.

  • timeout (int) – Command timeout in seconds.

  • output_file (str) – File path for output logging.

  • display (bool) – Show interactive execution output if True.

Returns:

A tuple (stdout, stderr).

Return type:

Tuple[str, str]

Raises:
execute_thread(command, retry=3, retry_interval=10, username=None, private_key_file=None, private_key_passphrase=None, output_file=None)[source]

Creates a thread that calls node.execute(). Results (i.e. stdout, stderr) from the thread can be retrieved with by calling thread.result()

Parameters:
  • command (str) – the command to run

  • retry (int) – the number of times to retry SSH upon failure

  • retry_interval (int) – the number of seconds to wait before retrying SSH upon failure

  • username (str) – username

  • private_key_file (str) – path to private key file

  • private_key_passphrase (str) – pass phrase

  • output_file (List[str]) – path to a file where the stdout/stderr will be written. None for no file output

Return type:

Thread

Returns:

a thread that called node.execute()

Raises:

Exception – if management IP is invalid

flush_all_os_interfaces()[source]

Flushes the configuration of all dataplane interfaces in the node.

flush_os_interface(os_iface, persistent=None)[source]

Flush the configuration of an interface in the node

Parameters:
  • os_iface (String) – the name of the interface to flush

  • persistent (bool) – if True, also remove persistent config (nmcli/netplan)

generate_template_context(skip=None)[source]

Build a Jinja2 template context dict for this node.

get_component(name, refresh=False)[source]

Retrieve a component associated with this node.

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

Parameters:
  • name (str) – Name of the component to retrieve

  • refresh (bool) – Whether to refresh the component from the latest FIM data

Returns:

The requested component

Return type:

Component

Raises:

Exception – If the component is not found

get_components(refresh=False)[source]

Gets a list of components associated with this node.

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

Parameters:

refresh (bool) – Refresh the component objects with latest FIM info

Returns:

a list of components on this node

Return type:

List[Component]

get_cores()[source]

Gets the number of cores on the FABRIC node.

Returns:

the number of cores on the node

Return type:

int

get_cpu_info()[source]

Get CPU Information for the Node and the host on which the VM is running

Return type:

dict

Returns:

cpu info dict

get_dataplane_os_interfaces()[source]

Gets a list of all the dataplane interface names used by the node’s operating system.

Returns:

interface names

Return type:

List[String]

get_disk()[source]

Gets the amount of disk space on the FABRIC node.

Returns:

the amount of disk space on the node

Return type:

int

get_fim()[source]

Get FABRIC Information Model (fim) object for the node.

get_fim_node()[source]

Get FABRIC Information Model (fim) node object.

Alias for get_fim() for backward compatibility.

get_host()[source]

Gets the hostname on the FABRIC node.

Returns:

the hostname on the node

Return type:

String

get_image()[source]

Gets the image reference on the FABRIC node.

Returns:

the image reference on the node

Return type:

String

get_image_type()[source]

Gets the image type on the FABRIC node.

Returns:

the image type on the node

Return type:

String

get_instance_name()[source]

Gets the instance name of the FABRIC node.

Returns:

the instance name of the node

Return type:

String

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

Gets a particular interface associated with a FABRIC node.

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) – interface name to search for

  • network_name (str) – network name to search for

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

  • raise_exception (bool) – if True, raise ResourceNotFoundError when the interface is not found; if False, return None. When None (default), falls back to the global FablibManager.raise_on_not_found setting.

Returns:

an interface on the node or None

Return type:

Optional[Interface]

Raises:

ResourceNotFoundError – if the interface is not found and raising is enabled

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

Gets a list of the interfaces associated with the FABRIC node.

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 objects with latest FIM info

  • output (str) – Return type - ‘list’ or ‘dict’

Returns:

interfaces on the node

Return type:

Union[Dict[str, Interface], List[Interface]]

get_ip_addrs()[source]

Get a list of ip address info from the node.

get_ip_routes()[source]

Get a list of routes from the node.

get_management_ip()[source]

Gets the management IP of the node (IPv6).

First attempts to read from the FIM topology. If the topology does not have the IP populated, falls back to the sliver info returned by the orchestrator.

Results are cached for performance.

Returns:

management IP

Return type:

String

get_management_os_interface()[source]

Gets the name of the management interface used by the node’s operating system, based on the default route.

Returns:

Name of the management interface or None if not found

Return type:

Optional[str]

get_networks(refresh=False)[source]

Get a list of networks attached to the node. :type refresh: bool :param refresh: Refresh the object with latest Fim info :type refresh: bool

static get_node(slice=None, node=None)[source]

Returns a new fablib node using existing FABRIC resources.

Note:

Not intended for API call.

Parameters:
  • slice (Slice) – the fablib slice storing the existing node

  • node (Node) – the FIM node stored in this fablib node

Returns:

a new fablib node storing resources

Return type:

Node

get_numa_info()[source]

Get Numa Information for the Node and the host on which the VM is running

Return type:

dict

Returns:

numa info dict

get_paramiko_key(private_key_file=None, get_private_key_passphrase=None)[source]

Get SSH pubkey, for internal use.

Returns:

an SSH pubkey.

Return type:

paramiko.PKey

get_post_update_commands()[source]

Get the list of commands that are to be run after boot.

static get_pretty_name_dict()[source]

Return mappings from non-pretty names to pretty names.

Pretty names are in table headers.

get_private_key()[source]

Gets the private key on the fablib node.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the private key on the node

Return type:

String

get_private_key_file()[source]

Gets the private key file path on the fablib slice.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the private key path

Return type:

String

get_private_key_passphrase()[source]

Gets the private key passphrase on the FABLIB slice.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the private key passphrase

Return type:

String

get_public_key()[source]

Gets the public key on fablib node.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the public key on the node

Return type:

String

get_public_key_file()[source]

Gets the public key file path on the fablib node.

Important! Slice key management is underdevelopment and this functionality will likely change going forward.

Returns:

the public key path

Return type:

String

get_ram()[source]

Gets the amount of RAM on the FABRIC node.

Returns:

the amount of RAM on the node

Return type:

int

get_requested_cores()[source]

Gets the requested number of cores on the FABRIC node.

Returns:

the requested number of cores on the node

Return type:

int

get_requested_disk()[source]

Gets the amount of disk space on the FABRIC node.

Returns:

the amount of disk space on the node

Return type:

int

get_requested_ram()[source]

Gets the requested amount of RAM on the FABRIC node.

Returns:

the requested amount of RAM on the node

Return type:

int

get_routes()[source]

Warning

This method is for fablib internal use, and will be made private in the future.

get_site()[source]

Gets the site this node is on.

Results are cached for performance.

Returns:

the site this node is on

Return type:

String

get_slice()[source]

Gets the fablib slice associated with this node.

Returns:

the fablib slice on this node

Return type:

Slice

get_sliver()[source]

Gets the node SM sliver.

Note:

Not intended as API call.

Returns:

SM sliver for the node

Return type:

Sliver

get_ssh_command()[source]

Gets an SSH command used to access this node from a terminal.

Returns:

the SSH command to access this node

Return type:

str

get_storage(name)[source]

Gets a particular storage associated with this node.

Parameters:

name (String) – the name of the storage

Raises:

Exception – if storage not found by name

Returns:

the storage on the FABRIC node

Return type:

Component

get_storage_cluster()[source]

Return the Ceph cluster name associated with this node, or None if none was specified.

Returns:

cluster name or None

Return type:

str or None

get_type()[source]

Gets the type of the network services.

Results are cached for performance.

Returns:

network service types

Return type:

NodeType

get_username()[source]

Gets the username on this fablib node.

Returns:

the username on this node

Return type:

String

has_storage()[source]

Check whether CephFS storage is enabled on this node.

Returns:

True if storage was enabled via enable_storage().

Return type:

bool

init_fablib_data()[source]

Initialize fablib data. Called by new_node().

ip_addr_add(addr, subnet, interface, persistent=None)[source]

Add an IP to an interface on the node.

Parameters:
  • addr (IPv4Address or IPv6Address) – IP address

  • subnet (IPv4Network or IPv6Network) – subnet.

  • interface (Interface) – the FABlib interface.

  • persistent (bool) – Override persistent config setting

ip_addr_del(addr, subnet, interface)[source]

Delete an IP to an interface on the node.

Parameters:
  • addr (IPv4Address or IPv6Address) – IP address

  • subnet (IPv4Network or IPv6Network) – subnet.

  • interface (Interface) – the FABlib interface.

ip_addr_list(output='json', update=False)[source]

Return the list of IP addresses assciated with this node.

Parameters:
  • output – Output format; "json" by default.

  • update – Setting this to True will force-update the cached list of IP addresses; default is False.

Returns:

When output is set to "json" (which is the default), the result of running ip -j[son] addr list, converted to a Python object. Otherwise the result of ip addr list.

ip_link_down(subnet, interface)[source]

Bring down a link on an interface on the node.

Parameters:
  • subnet (IPv4Network or IPv6Network) – subnet.

  • interface (Interface) – the FABlib interface.

ip_link_up(subnet, interface)[source]

Bring up a link on an interface on the node.

Parameters:
  • subnet (IPv4Network or IPv6Network) – subnet.

  • interface (Interface) – the FABlib interface.

ip_route_add(subnet, gateway, interface=None, persistent=None)[source]

Add a route on the node.

Parameters:
  • subnet (IPv4Network or IPv6Network) – The destination subnet

  • gateway (IPv4Address or IPv6Address) – The next hop gateway.

  • interface (Interface) – Optional interface for nmcli connection lookup

  • persistent (bool) – Override persistent config setting

ip_route_del(subnet, gateway)[source]

Delete a route on the node.

Parameters:
  • subnet (IPv4Network or IPv6Network) – The destination subnet

  • gateway (IPv4Address or IPv6Address) – The next hop gateway.

is_instantiated()[source]

Returns True if the node has been instantiated.

list_components(fields=None, output=None, quiet=False, filter_function=None, pretty_names=True, refresh=False)[source]

Lists all the components in the node 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.

Parameters:
  • output (str) –

    output format. Output can be one of:

    • "text": string formatted with tabular

    • "pandas": pandas dataframe

    • "json": string in json format

  • fields (List[str]) – list of fields (table columns) to show. JSON output will include all available fields/columns.

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

  • filter_function (lambda) – A lambda function to filter data by field values.

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

Returns:

table in format specified by output parameter

Return type:

Object

Here’s an example of fields:

fields=['Name','Model']

Here’s an example of filter_function:

filter_function=lambda s: s['Model'] == 'NIC_Basic'
list_interfaces(fields=None, output=None, quiet=False, filter_function=None, pretty_names=True, refresh=False)[source]

Lists all the interfaces in the node 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.

Parameters:
  • output (str) –

    Output format. Options are:

    • "text": string formatted with tabular

    • "pandas": pandas dataframe

    • "json": string in json format

  • fields (List[str]) – List of fields (table columns) to show. JSON output will include all available fields/columns.

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

  • filter_function (lambda) – A lambda function to filter data by field values.

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

Returns:

table in format specified by output parameter

Return type:

Object

Example of fields:

fields=['Name','MAC']

Example of filter_function:

filter_function=lambda s: s['Node'] == 'Node1'
list_networks(fields=None, output=None, quiet=False, filter_function=None, pretty_names=True, refresh=False)[source]

Lists all the networks attached to the nodes 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.

Parameters:
  • output (str) –

    Output format. Options are:

    • "text": string formatted with tabular

    • "pandas": pandas dataframe

    • "json": string in JSON format

  • fields (List[str]) – List of fields (table columns) to show. JSON output will include all available fields/columns.

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

  • filter_function (lambda) – A lambda function to filter data by field values.

  • pretty_names (bool) – Use “nicer” names in column headers. Default is True.

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

Returns:

table in format specified by output parameter

Return type:

Object

Example of fields:

fields=['Name','Type']

Example of filter_function:

filter_function=lambda s: s['Type'] == 'FABNetv4'
network_manager_start()[source]

(re)Start network manager on the node.

network_manager_stop()[source]

Stop network manager on the node.

static new_node(slice=None, name=None, site=None, avoid=None, validate=False, raise_exception=False)[source]

Creates a new FABRIC node on the slice.

Not intended for API use. Use slice.add_node() instead.

Parameters:
  • slice (SliceV2) – the fablib slice to build the new node on

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

  • site (str) – the name of the site to build the node on

  • avoid (List[str]) – a list of site names to avoid

  • validate (bool) – Validate node can be allocated w.r.t available resources

  • raise_exception (bool) – Raise exception if validation fails

Returns:

a new Node

Return type:

Node

numa_tune()[source]

Pin the memory for the VM to the numa node associated with the components

os_reboot()[source]

Request Openstack to reboot the VM. NOTE: This is not same as rebooting the VM via reboot or init 6 command. Instead this is like openstack server reboot.

pin_cpu(component_name, cpu_range_to_pin=None)[source]

Pin the cpus for the VM to the numa node associated with the component.

Parameters:
  • component_name (str) – Component Name

  • cpu_range_to_pin (str) – range of the cpus to pin; example: 0-1 or 0

ping_test(dst_ip)[source]

Test a ping from the node to a destination IP

Parameters:

dst_ip (String) – destination IP String.

Return type:

bool

poa(operation, vcpu_cpu_map=None, node_set=None, keys=None, bdf=None)[source]

Perform operation action on a VM; an action which is triggered by CF via the Aggregate

Parameters:
  • operation (str) – operation to be performed

  • vcpu_cpu_map (List[Dict[str, str]]) – map virtual cpu to host cpu map

  • node_set (List[str]) – list of numa nodes

  • keys (List[Dict[str, str]]) – list of ssh keys

  • bdf (List[str]) – list of PCI Ids

Raises:

Exception – in case of failure

Return type:

Union[Dict, str]

Returns:

State of POA or Dictionary containing the info, in case of INFO POAs

post_boot_tasks()[source]

Get the list of tasks to be performed on this node after boot.

remove_all_vlan_os_interfaces()[source]

Delete all VLAN os interfaces

remove_public_key(*, sliver_key_name=None, email=None, sliver_public_key=None)[source]

Remove public key to a node; - Remove user’s portal public key identified by sliver_key_name to the node - Remove portal public key identified by sliver_key_name for a user identified by email to the node - Remove public key from the sliver_public_key to the node

Parameters:
  • sliver_key_name (str) – Sliver Key Name on the Portal

  • email (str) – Email

  • sliver_public_key (str) – Public sliver key

:raises Exception in case of errors

remove_vlan_os_interface(os_iface=None, persistent=None)[source]

Remove one VLAN OS interface

Parameters:
  • os_iface (String) – the name of the VLAN interface to remove

  • persistent (bool) – Override persistent config setting

rescan_pci(component_name=None)[source]

Rescan PCI devices for a specific component or all components.

Parameters:

component_name (str) – Name of the component to rescan. If None, rescans all components.

Raises:

RuntimeError – If no PCI devices are found or if the rescan operation fails.

run_post_boot_tasks(log_dir='.')[source]

Run post-boot tasks. Called by config().

Post-boot tasks are list of commands associated with post_boot_tasks in fablib data.

run_post_update_commands(log_dir='.')[source]

Run post-update commands. Called by config().

Post-update commands are list of commands associated with post_update_commands in fablib data.

run_update_commands()[source]

Returns True if run_update_commands flag is set.

set_capacities(cores=2, ram=2, disk=10)[source]

Sets the capacities of the FABRIC node.

Parameters:
  • cores (int) – the number of cores to set on this node

  • ram (int) – the amount of RAM to set on this node

  • disk (int) – the amount of disk space to set on this node

set_host(host_name=None)[source]

Sets the hostname of this fablib node on the FABRIC node.

Parameters:

host_name (String) – the hostname. example: host_name=’renc-w2.fabric-testbed.net’

set_image(image, username=None, image_type='qcow2')[source]

Sets the image information of this fablib node on the FABRIC node.

Parameters:
  • image (String) – the image reference to set

  • username (String) – the username of this fablib node. Currently unused.

  • image_type (String) – the image type to set

set_instance_type(instance_type)[source]

Sets the instance type of this fablib node on the FABRIC node.

Parameters:

instance_type (String) – the name of the instance type to set

set_instantiated(instantiated=True)[source]

Mark node as instantiated. Called by config().

set_ip_os_interface(os_iface=None, vlan=None, ip=None, cidr=None, mtu=None, persistent=None)[source]

Configure IP Address on network interface as seen inside the VM :type os_iface: str :param os_iface: Interface name as seen by the OS such as eth1 etc. :type os_iface: String

Parameters:
  • vlan (String) – Vlan tag

  • ip (String) – IP address to be assigned to the tagged interface

  • cidr (str) – CIDR associated with IP address

  • mtu (String) – MTU size

  • persistent (bool) – Override persistent config setting

NOTE: This does not add the IP information in the fablib_data

set_run_update_commands(run_update_commands=True)[source]

Set run_update_commands flag.

set_site(site)[source]

Sets the site of this fablib node on FABRIC.

Parameters:

site – the site

set_username(username=None)[source]

Sets this fablib node’s username

Note:

Not intended as an API call.

Parameters:

username (str) – Optional username parameter. The username likely should be picked to match the image type.

show(fields=None, output=None, quiet=False, colors=False, pretty_names=True)[source]

Show a table containing the current node attributes.

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

Parameters:
  • output (str) –

    output format. Options are:

    • "text": string formatted with tabular

    • "pandas": pandas dataframe

    • "json": string in json format

  • fields (List[str]) – List of fields to show. JSON output will include all available fields.

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

  • colors (bool) – True to specify state colors for pandas output

Returns:

table in format specified by output parameter

Return type:

Object

Here’s an example of fields:

fields=['Name','State']
test_ssh()[source]

Test whether SSH is functional on the node.

Returns:

true if SSH is working, false otherwise (always False if no_ssh)

Return type:

bool

toDict(skip=None)[source]

Returns the node 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:

node attributes as dictionary

Return type:

dict

un_manage_interface(interface)[source]

Mark an interface unmanaged by Network Manager.

When using the nmcli backend, this is a no-op because NM manages the interface persistently. Only applies to legacy (ip) backend.

Parameters:

interface (Interface) – the FABlib interface.

update(fim_node)[source]

Update this node with a new FIM node and refresh components/interfaces.

upload_directory(local_directory_path, remote_directory_path, retry=3, retry_interval=10)[source]

Upload a directory to remote location on the node.

Makes a gzipped tarball of a directory and uploads it to a node. Then unzips and untars the directory at the remote_directory_path.

Parameters:
  • local_directory_path (str) – the path to the directory to upload

  • remote_directory_path (str) – the destination path of the directory on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Raises:
upload_directory_thread(local_directory_path, remote_directory_path, retry=3, retry_interval=10)[source]

Creates a thread that calls Node.upload_directory().

Results from the thread can be retrieved with by calling thread.result().

Parameters:
  • local_directory_path (str) – the path to the directory to upload

  • remote_directory_path (str) – the destination path of the directory on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Returns:

a thread that called node.upload_directory()

Return type:

Thread

Raises:

Exception – if management IP is invalid

upload_file(local_file_path, remote_file_path='.', retry=3, retry_interval=10)[source]

Upload a local file to a remote location on the node.

Parameters:
  • local_file_path (str) – the path to the file to upload

  • remote_file_path (str) – the destination path of the file on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Raises:
upload_file_thread(local_file_path, remote_file_path='.', retry=3, retry_interval=10)[source]

Creates a thread that calls node.upload_file().

Results from the thread can be retrieved with by calling thread.result().

Parameters:
  • local_file_path (str) – the path to the file to upload

  • remote_file_path (str) – the destination path of the file on the node

  • retry (int) – how many times to retry SCP upon failure

  • retry_interval (int) – how often to retry SCP on failure

Returns:

a thread that called node.execute()

Return type:

Thread

Raises:

Exception – if management IP is invalid

validIPAddress(IP)[source]

Checks if the IP string is a valid IP address.

Parameters:

IP (String) – the IP string to check

Returns:

the type of IP address the IP string is, or ‘Invalid’

Return type:

String