Base¶
BaseVIM¶
-
class
tangotest.vim.base.
BaseVIM
¶ This is a base class for interaction with a virtual infrastructure manager. It can not be used directly and must be subclassed for each platform.
-
start
()¶ Run the VIM or connect to the running VIM.
-
stop
()¶ Stop the VIM or disconnect from it.
-
add_instances_from_package
(package, package_format=None)¶ Run VNFs using a package. The library will run all the VNFs from the package and connect the according to the descriptors.
Parameters: - package (str) – The path to the package
- package_format (str) – “tango” or “sonata”
Returns: The list of (BaseInstance)s
Return type: list
-
add_instance_from_image
(name, image, interfaces=None, **args)¶ Run an image.
Parameters: - name (str) – The name of an instance
- image (str) – The name of an image
- interfaces (int) or (list) or (dict) – Network configuration
- args – Platform-specific parameters
Returns: The added instance
Return type:
-
add_instance_from_source
(name, path, interfaces=None, image_name=None, **args)¶ Build and run an image on the VIM.
Parameters: - name (str) – The name of an instance
- path (str) – The path to the directory containing Dockerfile
- interfaces (int) or (list) or (dict) – Network configuration
- image_name (str) – The name of an image. Default: tangotest<name>
- args – Platform-specific parameters
Returns: The added instance
Return type:
-
add_test_vnf
(name, vnf_name)¶ Add addtitional test VNFs.
Parameters: - name (str) – The name of an instance
- vnf_name (str) – The name of the VNF
Returns: The added instance
Return type:
-
add_link
(src_vnf, src_if, dst_vnf, dst_if, sniff=False, **kwargs)¶ Add a link between two instances.
Parameters: - src_vnf (str) – The name of a source VNF
- src_if (str) – The name of a source interface
- dst_vnf (str) – The name of a destination VNF
- dst_if (str) – The name of a destination interface
- sniff (bool) – Add the sniffer to the link
Returns: ‘’True’’ if successfull
Return type: (bool)
-
get_traffic
(src_vnf, src_if, dst_vnf, dst_if)¶ Get sniffed traffic.
Parameters: - src_vnf (str) – The name of a source VNF
- src_if (str) – The name of an interface of a source VNF
- dst_vnf (str) – The name of a destination VNF
- dst_if (str) – The name of an interface of a destination VNF
Returns: Sniffed packets
Return type: (generator)
-
BaseInstance¶
-
class
tangotest.vim.base.
BaseInstance
¶ A representation of the abstract instance. Must be subclassed for each platform. Should not be created manually but by the VIM adapter.
-
execute
(cmd, stream=False, **kwargs)¶ Execute a command or script on the instance.
Parameters: cmd (str) – The command or path to the script Returns: Output of the executed command or script Return type: (str)
-
get_ip
(interface)¶ Get an IP address of an interface.
Parameters: interface (str) – The name of the interface Returns: - The IP address of the interface or None if the interface doesn’t exist
- or if the interface has no IP address
Return type: (str) or (None)
-
get_mac
(interface)¶ Get a MAC address of an interface.
Parameters: interface (str) – The name of the interface Returns: The MAC address of the interface or None if the interface doesn’t exist Return type: (str) or (None)
-
get_file
(path)¶ Get file content.
Parameters: path (str) – A path to the file Returns: The content of the file Return type: (str)
-
get_journal
(params)¶ Get records from systemd journal.
Parameters: params (str) – Parameters of the request Returns: The list of records Return type: (list)
-