MFLib Core¶
MFLib’s Core functions are defined in this class. This class is the base class for all MFLib classes and is not meant to be used directly.
- class mflib.core.Core(local_storage_directory='/tmp/mflib', mf_repo_branch='main', logging_level=10)¶
MFLib core contains the core methods needed to create and interact with the Measurement Framework installed in a slice. It is not intended to be used by itself, but rather, it is the base object for creating Measurement Framework Library objects.
- property bootstrap_status_file¶
The full path to the local copy of the bootstrap status file.
- Returns:
The full path tp the local copy of the bootsrap status file.
- Return type:
String
- property common_hosts_file¶
The full path to a local copy of the hosts.ini file.
- Returns:
The full path to a local copy of the hosts.ini file.
- Return type:
String
- core_class_version = '1.0.40'¶
An updatable version for debugging purposes to make sure the correct version of this file is being used. Anyone can update this value as they see fit. Should always be increasing.
- Returns:
Version.sub-version.build
- Return type:
String
- create(service, data=None, files=[])¶
Creates a new service for the slice.
- Parameters:
service (String) – The name of the service.
data (JSON serializable object)
files (List of Strings) – List of filepaths to be uploaded.
- Returns:
Dictionary of creation results.
- Return type:
dict
- download_log_file(service, method)¶
Download the log file for the given service and method. Downloaded file will be stored locally for future reference. :param service: The name of the service. :type service: String :param method: The method name such as create, update, info, start, stop, remove. :type method: String :return: Writes file to local storage and returns text of the log file. :rtype: String
- download_service_file(service, filename, local_file_path='')¶
Downloads service files from the meas node and places them in the local storage directory. Denies the user from downloading files anywhere outside the service directory :param service: Service name :type service: String :param filename: The filename to download from the meas node. :param local_file_path: Optional filename for local saved file. :type local_file_path: String
- get_bootstrap_status(force=True)¶
Returns the bootstrap status for the slice. Default setting of force will always download the most recent file from the meas node. The downloaded file will be stored locally for future reference at self.bootstrap_status_file.
- Parameters:
force (Boolean) – If downloaded file already exists locally, it will not be downloaded unless force is True. .
- Returns:
Bootstrap dict if any type of bootstraping has occured, Empty dict otherwise.
- Return type:
Dictionary
- get_mfuser_private_key(force=True)¶
Downloads the mfuser private key. Default setting of force will always download the most recent file from the meas node. The downloaded file will be stored locally for future reference at self.local_mfuser_private_key_filename.
- Parameters:
force (Boolean) – If downloaded file already exists locally, it will not be downloaded unless force is True.
- Returns:
True if file is found, false otherwise.
- Return type:
Boolean
- property grafana_tunnel¶
Returns the command for createing an SSH tunnel for accesing Grafana.
- Returns:
ssh command
- Return type:
String
- property grafana_tunnel_local_port¶
If a tunnel is used for grafana, this value must be set for the port. :returns: port number :rtype: String
- info(service, data=None)¶
Gets inormation from an existing service. Strictly gets information, does not change how the service is running.
- Parameters:
service (String) – The name of the service.
data (JSON Serializable Object) – Data to be passed to a JSON file place in the service’s meas node directory.
- Returns:
Dictionary of info results.
- Return type:
dict
- property kibana_tunnel¶
Returns the command for createing an SSH tunnel for accesing Kibana.
- Returns:
ssh command
- Return type:
String
- property kibana_tunnel_local_port¶
If a tunnel is used for Kibana, this value must be set for the port
- property local_mfuser_private_key_filename¶
The local copy of the private ssh key for the mfuser account.
- Returns:
The local copy of the private ssh key for the mfuser account.
- Return type:
String
- property local_mfuser_public_key_filename¶
The local copy of the public ssh key for the mfuser account.
- Returns:
The local copy of the public ssh key for the mfuser account.
- Return type:
String
- property local_slice_directory¶
The directory where local files associated with the slice are stored.
- Returns:
The directory where local files associated files are stored.
- Return type:
str
- property log_directory¶
The full path for the log directory.
- Returns:
The full path to the log directory.
- Return type:
String
- property meas_node¶
The fablib node object for the Measurement Node in the slice.
- Returns:
The fablib node object for the Measurement Node in the slice.
- Return type:
fablib.node
- property meas_node_ip¶
The management ip address for the Measurement Node
- Returns:
ip address
- Return type:
String
- remove(services=[])¶
Stops a service running and removes anything setup on the experiment’s nodes. Service will then need to be re-created using the create command before service can be started again.
- Parameters:
services (List of Strings) – The names of the services to be removed.
- Returns:
List of remove result dictionaries.
- Return type:
List
- set_core_logger()¶
Sets up the core logging file. Note that the self.logging_filename will be set with the slice name when the slice is set. Args: filename (_type_, optional): _description_. Defaults to None.
- property slice_name¶
Returns the name of the slice associated with this object.
- Returns:
The name of the slice.
- Return type:
String
- property slice_username¶
The default username for the Measurement Node for the slice.
- Returns:
username
- Return type:
String
- start(services=[])¶
Restarts a stopped service using existing configs on meas node.
- Parameters:
services (List of Strings) – The name of the services to be restarted.
- Returns:
List of start result dictionaries.
- Return type:
List
- stop(services=[])¶
Stops a service, does not remove the service, just stops it from using resources.
- Parameters:
services (List of Strings) – The names of the services to be stopped.
- Returns:
List of stop result dictionaries.
- Return type:
List
- property tunnel_host¶
If a tunnel is used, this value must be set for the localhost, Otherwise it is set to empty string.
- Returns:
tunnel hostname
- Return type:
String
- update(service, data=None, files=[])¶
Updates an existing service for the slice.
- Parameters:
service (String) – The name of the service.
data (JSON Serializable Object) – Data to be passed to a JSON file place in the service’s meas node directory.
files (List of Strings) – List of filepaths to be uploaded.
- Returns:
Dictionary of update results.
- Return type:
dict
- upload_service_directory(service, local_directory_path, force=False)¶
Uploads the given local directory to the given service’s directory on the meas node. :param service: Service name for which the files are being upload to the meas node. :type service: String :param local_directory_path: Directory path on local machine. :type local_directory_path: String :param force: Whether to overwrite existing directory, if it exists. :type force: Bool :raises: Exception: for misc failures…. :return: ? :rtype: ?
- upload_service_files(service, files)¶
Uploads the given local files to the given service’s directory on the meas node. Denies the user from uploading files anywhere outside the service directory :param service: Service name for which the files are being upload to the meas node. :type service: String :param files: List of file paths on local machine. :type files: List :raises: Exception: for misc failures…. :return: ? :rtype: ?