The subpackage fabrictestbed.slice_editor can be used to specify or design the resources that are needed to be reserved.
Class ExperimentTopology
This class can be used to define an experiment topology. You can instantiate the class into an object, and then use its methods to add nodes and links etc…
<!–
Todo / Note: there’s a typo in the docs that are accessible through python’s help() function. “Define an user topology model”.
–>
from fabrictestbed.slice_editor import ExperimentTopology
t = ExperimentTopology()
Constructor
Param |
graph_file A file that contains a graph. See the concept of a graph. |
Param |
graph_string A string that contains a graph. See the concept of a graph. |
Param |
logger Todo: describe. |
t = ExperimentTopology()
Nodes
Attribute
nodesGet only |
Returns a list of nodes that have been added to the ExperimentTopology. {Node name: {‘capacities’: { core: Number of cores, ram: Amount of RAM, disk: Amount of disk space, }. ‘image_ref’: The operating system or the distro of the image. ‘image_type’: ‘qcow2’ Todo: what does this mean? ‘name’: Node name. Todo: the node name is already the key of the object. ‘site’: The site at which the node is deployed. ‘type’: The type of the node. Example: VM is Virtual Machine.} } |
Links
Attribute
linksGet only |
Returns a list of links that have been added to the ExperimentTopology. {Link Name: {‘layer’: The layer in which the link is. Todo: Where are they defined?, ‘name’: The name given to the link, ‘type’: Todo: what is the type?}[Network interfaces connected to the link]} |
Interface List
Attribute
interface_listGet only |
List all interfaces of the topology as a dictionary. Todo: elaborate more. Does “interfaces” mean “network interfaces”? ({‘capacities’: ‘{ bw: 25G, }’, ‘name’: ‘nic1-p1’, ‘type’: ‘TrunkPort’}, {‘capacities’: ‘{ bw: 25G, }’, ‘name’: ‘nic1-p2’, ‘type’: ‘TrunkPort’}) |
Add Node
Param str |
name A string that names the link. |
Param str |
node_id Todo: what is the ID? |
Param |
site The site at which you want to create the node. See the concept of sites. |
Param |
ntype The node type, which is fabrictestbed.slice_editor.NodeType. See NodeType. |
Return |
Node A Node object. See Node. |
t = ExperimentTopology()
n1 = t.add_node(name='n1', site='RENC')
Add Link
Param str |
name A string that names the link. |
Param str |
node_id Todo: what is the ID? |
Param |
ltype Todo: what are the link types and descriptions? |
Param |
interfaces A list of the interfaces which this link connects. |
Param |
layer The layer in which the link should be made. Todo: Where are the layers defined? |
Param str |
technology Todo: What is technology? |
Todo: Shouldn’t layout be layout=networkx.drawing.layout.spring_layout)? If so, we need to fix the documentation that we get from python’s help(). It shows “layout=<function fruchterman_reingold_layout at 0x7fd0c264d940></function>”.
ping_link = experiemnt.add_link(
name='ping_link',
ltype=LinkType.DAC,
layer=Layer.L2,
interfaces=[
list(filter(
lambda iff:(iff.name == 'renc1_demo1_nic1'+'-p1'),
experiemnt.interface_list))[0],
list(filter(
lambda iff: (iff.name == 'uky1_demo1_nic1'+'-p1'),
experiemnt.interface_list))[0]]
)
Draw The Topology
Param |
file_name Save figure to a file. Drawing type is determined by extension (e.g. “.png”). |
Param |
interactive Use interactive pyplot mode. |
Param |
topo_detail Level of detail to use in drawing. Defaults to level 1, which is “Derived”. |
Param |
layout Use one of available layout algorithms in NetworkX. Defaults to “spring_layout”. |
advertised_topology.draw()
Load Topology
Param |
file_name The name of the file to load the topology from. |
Param |
graph_string The string to load the topology from. |
t.load(graph_string=gs)
Remove Link
Param |
name The name of the link to remove. |
#Todo: add code example.
Remove Node
Param |
name The name of the node to be removed. |
t.remove_node("n1")
Serialize Topology
Param |
file_name If provided, the graph string is going to be saved to a file. Otherwise, the function is going to return a string. |
Return |
A string containing GraphML if file_name is None. |
slice_graph = t.serialize()
status, reservations = slice_manager.create(
slice_name='JupyterSlice2',
slice_graph=slice_graph,
ssh_key=ssh_key)
Enum NodeType
Enum
fabrictestbed.slice_editor.NodeTypeServer |
Todo: elaborate. What is the difference between this and a VM? |
VM |
A Virtual Machine. A full operating system, virtualized on top of the hypervisor. |
Container |
A Container. A package of code along with its dependencies that is ready to run on top of any computing environment. |
Switch |
A data link layer (layer 2) device that can route packets to and from network interfaces connected to it. |
NAS |
Network-Attached Storage. A data store that provides data to other clients over the network. |
Class Node
This class represents nodes in your experiment. When you use the .add_node() function, you get an instance of this class.
And then, you can use the functions of this class to customize the node according to your needs.
Constructor
Todo: even though the user shouldn’t call the constructor on his own, should we still document it? If not, then we should just delete this part.
|
Components
Attribute
componentsGet only |
A dictionary of the components that have been added to the node. |
Interfaces
Attribute
interfacesGet only |
A dictionary of the network interfaces that the node has. |
Interfaces (list)
Attribute
interface_listGet only |
A k-Tuple object of the network interfaces that the node has, where k is the number of tuples. |
Direct Interfaces
Attribute
direct_interfacesGet only |
Todo: what is the difference between this and interfaces or interface_list? |
Switch Fabrics
Attribute
switch_fabricsGet only |
The switch fabrics that the node has. |
Add Component
Param |
name A name that you can give to the component, in order to be able to refer to it later. |
Param |
node_id You can optionally set an ID for the node. If this argument is not provided, and ID will be automatically generated for the node. |
Param |
ctype The component type, An instance of the enum ComponentType. See ComponentType. |
Param |
model After specifying the component type, here you can specify what model of that component you want. Todo: list all models of each component type. |
Param |
switch_fabric_node_id Switch fabric identifier for substrate models. Todo: elaborate. |
Param |
interface_node_ids Interface identifiers for substrate models. Todo: elaborate. |
Param |
interface_labels List of labels for interfaces in substrate models. Todo: elaborate. |
Return |
Component A Component object. Todo: document the Component class and link to it here? |
n1 = t.add_node(name='n1', site='RENC')
# Set capacities
cap = Capacities()
cap.set_fields(core=4, ram=4, disk=10)
# Set Properties
n1.set_properties(capacities=cap, image_type='qcow2',
image_ref='default_centos_8')
# Add PCI devices
n1.add_component(ctype=ComponentType.SmartNIC,
model='ConnectX-5', name='nic1')
Add Switch Fabric
Param |
name A string that names the switch fabric. |
Param |
node_id You can optionally set an ID for the node. If this argument is not provided, and ID will be automatically generated for the node. |
Param |
layer Layer 1 or 2 or 3. An instance of fabrictestbed.slice_editor.Layer. See the concept of Layers. |
Return |
SwitchFabric A SwitchFabric object. Todo: document it and link to it? |
#Todo: add code example.
Get Component
Param |
name The name of the component that you want to get. |
Return |
Component A Component object. Todo: document the Component class and link to it here? |
n2 = t2.add_node(name='n2', site='UKY')
#Set properties
n2.set_properties(capacities=cap, image_type='qcow2',
image_ref='default_centos_8')
#Add PCI devices
interface2 = n2.add_component(ctype=ComponentType.SmartNIC,
model='ConnectX-5', name='nic2')
t2.remove_node("n1")
c1 = n2.get_component("nic2")
Get Property Of Node
Param |
pname The name of the property to be retrieved. |
Return |
Object The property. |
Remove Component
Param |
name The name of the component to be removed. |
n2 = t2.add_node(name='n2', site='UKY')
#Set properties
n2.set_properties(capacities=cap, image_type='qcow2',
image_ref='default_centos_8')
#Add PCI devices
interface2 = n2.add_component(ctype=ComponentType.SmartNIC,
model='ConnectX-5', name='nic2')
interface2 = n2.add_component(ctype=ComponentType.SmartNIC,
model='ConnectX-5', name='nic3')
t2.remove_node("n1")
n2.remove_component("nic2")
Remove Switch Fabric
Param |
name The name of the switch fabric to be removed. |
#Todo: Make a code example.
Set Properties Of Node
#Todo: Make a code example.
Set Property Of Node
Param |
pname The name of the property to be set. |
Param |
pval The value of the property to be set. |
#Todo: Make a code example.
Class Capacities
This class can be used to specify the hardware resources that you want to allocate to your slivers. You need to instantiate an object of the class and use set_fields() to specify them. Then you can pass the instatiated object as the “capacities” parameter in the slivers you create.
Constructor
Param |
graph_file A file that contains a graph. See the concept of a graph. |
Param |
graph_string A string that contains a graph. See the concept of a graph. |
Param |
logger Todo: describe. |
cap = Capacities()
cap.set_fields(core=4, ram=4, disk=100)
Todo: do those?
| negative_fields(self) -> List[str]
| returns list of fields that are negative
| :return:
|
| positive_fields(self, fields: List[str]) -> bool
| Return true if indicated fields are positive >0
| :param fields:
| :return:
Set Capacity Fields
cpu |
Todo: What is cpu? |
core |
Number of CPU cores. |
ram |
Amount of RAM in Gigabytes. |
disk |
Amount of disk space in Gigabytes. |
bw |
Amount of Bandwidth in Gbps. |
unit |
Todo: What are units? |
Raises |
CapacityException Raised you try to set a non-existent field. |
Return |
self For call chaining. |
cap = Capacities()
cap.set_fields(core=4, ram=4, disk=100)
Set Capacity Fields From JSON.
Param |
json_string The JSON string to set the parameters from. The parameters are the same parameters of the set_fields() function.See set_fields(). |
Return |
self For call chaining. |
#Todo: write a code example.
List Fields Of Capacity
Return |
A sorted list of the fields that were set. |
print(cap.list_fields())
Capacity To Dictionary
Return |
A dictionary of all the fields that have been set. Empty fields are skipped. None is returned if all fields are empty. |
print(cap.to_dict())
Capacity To JSON
Return |
A JSON string of the fields that have been set. Empty string is returnd if there are no values. |
print(cap.to_json())
Enum ComponentType
The ComponentType
enum can be used to add components to nodes.
Enum
fabrictestbed.slice_manager.StatusGPU |
A GPU card. |
SmartNIC |
A type of network cards (Network Interface Controller) that is more performant than the SharedNIC. |
SharedNIC |
A type of network cards (Network Interface Controller) that is less performant than the SmartNIC. |
FPGA |
A programmable integrated circuit. |
NVME |
A type of persistent storage which is faster than mechanical storage. |