The subpackage fabrictestbed.slice_manager contains the class SliceManager
, and the enum Status
.
from fabrictestbed.slice_manager import SliceManager, Status
Enum Status
The fabrictestbed.slice_manager.Status
enum is used to indicate whether something was successful or not. It is returned by, for example, function calls to indicate whether it was successful or not.
1 | OK Operation executed successfully. |
2 | INVALID_ARGUMENTS Arguments are invalid. |
3 | FAILURE Operation was unsuccessful. |
from fabrictestbed.slice_manager import Status
Class SliceManager
The fabrictestbed.slice_manager.SliceManager
class is used for things like communicating with the FABRIC test bed to determine the state of your slices, slivers, etc…, as well as issuing requests to reserve resources.
Constructor
Param |
cm_host Credit Manager Host. It should be set to the value of the environment variable ‘FABRIC_CREDMGR_HOST’. |
Param |
oc_host Orchestrator Client Host. It should be set to the value of the environment variable ‘FABRIC_ORCHESTRATOR_HOST’. |
Param |
token_location Todo |
Param |
project_name A string that names the project. |
Param |
scope |
Create Slice
The create
function lets you create a slice according to the resources provided in the slice_graph variable.
Param |
token The FABRIC identity token. It can be retrieved (or renewed if expired) by issuing slice_manager.refresh_tokens(). |
Param str |
slice_name A string that names the slice. |
Param str |
ssh_key The public key of an ssh key-pair (which is typically in a file named ‘id_rsa.pub’). The nodes in the slice can later be accessed using the private key of the key-pair. You typically need to read the public key file and pass it to this parameter. |
Param |
topology Todo: what is topology? |
Param str |
slice_graph Slice graph string. A graph string can be generated using the slice_editor subpackage. See fabrictestbed.slice_editor. |
Return |
Tuple(Status, Slivers/Exception) Status is fabrictestbed.slice_manager.Status. Slivers/Exception contains, in case of success, a JSON containing the slivers created. In case of failure, it contains an Exception. Todo: Should we state the “Reservation” object as something standard? Or do we just use it internally and not let the user care about it? [{ “graph_node_id”: “fe716383-8619-4bce-8dc8-9c432a16349a”, Todo: what is this? “join_state”: “None_”, Todo: what is this? “lease_end”: The date and time at which the resource will be deleted. “reservation_id”: The ID of the resource. “reservation_state”: The reservation state (whether it’s running or configuring …etc). Todo: List all possibilities and explain them? “resource_type”: The type of the resource or sliver. See NodeType. “slice_id”: The ID of the slice in which the resource (or the sliver) is contained. }] |
status, reservations = slice_manager.create(
slice_name='JupyterSlice2',
slice_graph=slice_graph,
ssh_key=ssh_key)
Todo / Note: There’s a mismatch between the docs that we get with python’s help() function and the code.
Delete Slice
The delete
function allows you to delete a slice. You specify the slice by providing its ID through the slice_id
parameter.
Param |
slice_id The slice ID of the slice to be deleted |
Return |
Tuple(Status, Exception) Status is fabrictestbed.slice_manager.Status. Exception is either None or, in case of failure, contains an Exception. |
status, result = slice_manager.delete(slice_id=slice_id)
Query Slices
The slices
function gets information about all slices.
Return |
Tuple(Status, Slices/Exception) Status is fabrictestbed.slice_manager.Status. Slices/Exception contains, in case of success, a JSON containing an array of slices and information about them. In case of failure, it contains an Exception. { “graph_id”: A unique string that identifies the graph. See the concept of a graph. “slice_id”: A unique string that identifies the slice. “slice_name”: The name that was given to the slice. “slice_state”: The state of the slice and whether it’s ready to function. “StableOK” means that the slice is in a ready state and you can access the machines that you have created. Todo: enumerate? } |
status, slices = slice_manager.slices()
Get Slice
The get_slice
function lets you view a slice’s information.
Param |
slice_id The slice ID of the slice to view information of. |
Return |
Tuple(Status, Slice/Exception) Status is fabrictestbed.slice_manager.Status. Slices/Exception contains, in case of success, information about the slice requested. In case of failure, it contains an Exception. { core: Total cores ram: Total amount of RAM disk: Total amount of disk space } Node name [Node type]: { core: Number of cores ram: Amount of RAM disk: Amount of disk space } |
status, slice_obj = slice_manager.get_slice(slice_id=slice_id)
Refresh Tokens
Use this function to refresh the tokens. The function generates a new identity token and a new refresh token.
User is expected to invoke refresh token API (this function) before invoking any other APIs (functions) to ensure the token is not expired.
User is also expected to update the returned refresh token in the JupyterHub environment.
Return |
Tuple(id_token, refresh_token) id_token is the identity token. See the concept of identity tokens. refresh_token is the refresh token. See the concept of refresh tokens. |
Raises |
SliceManagerException(id_token) |
id_token, refresh_token = slice_manager.refresh_tokens()
Renew Slice
renew
function lets you extend the end time of a lease.Param |
slice_id The ID of the slice to be renewed. |
Param |
new_lease_end_time A date and time string that specifies the requested end date of the lease. Format: “%Y-%m-%d %H:%M:%S”. Example: “2022-01-01 00:00:00”. |
Return |
Tuple(Status, None/Reservations) Status is fabrictestbed.slice_manager.Status. None/Reservations contains a list of reservation IDs of reservations that couldn’t be extended, or None in case there were no issues. |
slice_manager.renew(slice_id=slices[0].slice_id,
new_lease_end_time="2023-01-01 00:00:00")
Query Resources
resources
function lets you get the resources available for reservation.Param |
level The level of details. |
Return |
Tuple(Status, Resources/Exception) Status is fabrictestbed.slice_manager.Status. Resources/Exeption contains, in case of success, a description of the resources available. In case of failure, it contains an Exception. Site Name: { Number of CPUs: Available/Total, core: 90/96, Todo: what are cores? Amount of RAM: Available/Total (in Gigabytes), Amount of storage: Available/Total (in Gigabytes), Units: Available/Total, } Components: Component name: component description { [disk: Available/Total (in Gigabytes)], units: Available/Total } Site Interfaces: |
status, advertised_topology = slice_manager.resources()
(‘INTERNAL SERVER ERROR’, ‘”error=\\”server_error\\”\\nerror_description=\\”class+edu.uiuc.ncsa.myproxy.oa4mp.oauth2.storage.OA2SQLTStore
+cannot+be+cast+to+class+edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE+%28edu.uiuc.ncsa.myproxy.oa4mp.oauth2.storage.OA2SQLTStore
+and+edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE+are+in+unnamed+module+of+loader+org.apache.catalina.loader.WebappClassLoader+%40748cc258%29\\”\\n”\n’)
Revoke Token
revoke_token
function lets you revoke or invalidate the refresh token.Param str |
refresh_token The FABRIC refresh token that is initially stored in the evironment variable ‘CILOGON_REFRESH_TOKEN’. It can be renewed by issuing slice_manager.refresh_tokens(). |
Return |
response Todo: waiting for it to get fixed. Also the API changed. Try it again. |
Raises |
Exception |
slice_manager.revoke_token(refresh_token=refresh_token)
Get Slice Status
slice_status
lets you get status information about a slice. You can specify the slice by passing in its ID to the slice_id
parameter.Param |
slice_id The ID of the slice that you want to see the status of. |
Return |
Tuple(Status, SliceStatus/Exception) Status is fabrictestbed.slice_manager.Status. SliceStatus/Exception contains, in case of success, a JSON containing the status of the slice. In case of failure, it contains an Exception. { “graph_id”: A unique string that identifies the graph. See the concept of a graph. “slice_id”: A unique string that identifies the slice. “slice_name”: The name that was given to the slice. “slice_state”: The state of the slice and whether it’s ready to function. “StableOK” means that the slice is in a ready state and you can access the machines that you have created. Todo: enumerate? } |
status, slice_status = slice_manager.slice_status(slice_id=slice_id)
Get Sliver Status
The sliver_status
lets you get information about a sliver (which is typically a node in your slice).
Param |
slice_id The slice ID of the slice that contains the sliver. It can be found in the object returned from the .create() call. You can set it to the “slice_id” variable. See .create(). |
Param |
sliver_id The sliver ID of the sliver you want to get information about. It can be found in the object returned from the .create() call. You can set it to the “reservation_id” variable. See .create(). |
Return |
Tuple(Status, SliverStatus/Exception) Status is fabrictestbed.slice_manager.Status. SliverStatus/Exception contains, in case of success, a JSON containing the status of the requested sliver. In case of failure, it contains an Exception. { “capacities”: “{\”core\”: Number of cores, \”disk\”: Amount of disk space, \”ram\”: Amount of RAM}”, “graph_node_id”: An ID that identifies the graph. See the concept of a graph. “join_state”: “NoJoin”, Todo: what is this? “labels”: Labels given to the sliver, if any. “management_ip”: The IP address that can be used to access the sliver, typically using SSH. “name”: The name given to the sliver. “notices”: A string contining details. “reservation_id”: The ID of the sliver. “reservation_state”: The reservation state (whether it’s running or configuring …etc). Todo: List all possibilities and explain them? “resource_type”: The type of the sliver. See NodeType. “site”: The site at which the sliver is. “slice_id”: The ID of the slice in which the sliver (or the sliver) is contained. } |
status, sliver_status = slice_manager.sliver_status(
slice_id=slice_id,
sliver_id=s.reservation_id)
Query Slivers
slivers
function lets you get information about all slivers.Param |
slice_id The slice ID to be queried. It can be found in the object returned from the .create() call. You can set it to the “slice_id” variable. See .create(). |
Param optional |
sliver_id The sliver ID to be queried. It can be found in the object returned from the .create() call. You can set it to the “reservation_id” variable. See .create(). |
Return |
Tuple(Status, SliversStatus/Exception) Status is fabrictestbed.slice_manager.Status. SliversStatus/Exception contains, in case of success, a JSON containing an array containing the status of all the slivers. In case of failure, it contains an Exception. [{ “capacities”: “{\”core\”: Number of cores, \”disk\”: Amount of disk space, \”ram\”: Amount of RAM}”, “graph_node_id”: An ID that identifies the graph. See the concept of a graph. “join_state”: “NoJoin”, Todo: what is this? “labels”: Labels given to the sliver, if any. “management_ip”: The IP address that can be used to access the sliver, typically using SSH. “name”: The name given to the sliver. “notices”: A string contining details. “reservation_id”: The ID of the sliver. “reservation_state”: The reservation state (whether it’s running or configuring …etc). Todo: List all possibilities and explain them? “resource_type”: The type of the sliver. See NodeType. “site”: The site at which the sliver is. “slice_id”: The ID of the slice in which the sliver (or the sliver) is contained. }] |
status, slivers = slice_manager.slivers(
slice_id=reservations[1].slice_id,
sliver_id=reservations[1].reservation_id)