Forum Replies Created
-
AuthorPosts
-
@Xusheng, the rough Python code is tailored to work with my IntelliJ IDE. However it does contain good examples of what environmental variables FABLib expects, how to call functions in FABLib, etc.. In short, I would write your own Python by grabbing the useful bits from mine.
My advice would be to start with copying the FABLib commands documented on the
start_here.ipynb --> create_slice.ipynb
Jupyter Lab notebook to your local Python script file.If you would like, feel free to cannibalize my very rough Python code on GitHub.
If you are looking to interact with Fabric via Python I have had a lot of success with the FABLib API.
Here is our Conda
environment.yml
file:# conda env create --file environment.yml name: uofu-fabrictestbed channels: - defaults dependencies: - pip=21.2.4 - python=3.9.12 - pip: - fabrictestbed-extensions==1.3.0
While testing this in Jupyter I am yes.
cat .tokens.json
does show an up-to-datecreated_at
but the oscillation between the group membership or invalid refresh token errors remain. Komal has been assigned my ticket and hopefully he can do some behind the scenes magic to clear this up.@Paul I am following your Configure your Jupyter Environment docs.
I believe all the variables are present below.
cluster_logger.info('Setting up OS environmental variables for FABlib...') os.environ['FABRIC_CREDMGR_HOST'] = 'cm.fabric-testbed.net' os.environ['FABRIC_ORCHESTRATOR_HOST'] = 'orchestrator.fabric-testbed.net' os.environ['FABRIC_BASTION_HOST'] = 'bastion-1.fabric-testbed.net' os.environ['FABRIC_PROJECT_ID'] = config['secrets']['fabric_project_id'] os.environ['FABRIC_BASTION_USERNAME'] = config['secrets']['fabric_bastion_username'] os.environ['FABRIC_BASTION_KEY_LOCATION'] = f"{fabric_config_dir}/fabric-bastion-key" os.environ['FABRIC_SLICE_PRIVATE_KEY_FILE'] = f"{fabric_config_dir}/slice_key" os.environ['FABRIC_SLICE_PUBLIC_KEY_FILE'] = f"{fabric_config_dir}/slice_key.pub" os.environ['FABRIC_LOG_LEVEL'] = 'INFO' os.environ['FABRIC_LOG_FILE'] = f"{fabric_config_dir}/fablib.log" os.environ['FABRIC_TOKEN_LOCATION'] = f"{fabric_config_dir}/token.json"
That membership error does shift to an “invalid refresh token” that won’t go away despite regenerating new token JSON files (submitted as FIP-91).
Is there a work-around for this error outside of Jupyter Lab? I download a fresh token from the Portal, set
FABRIC_TOKEN_LOCATION
and received:Traceback (most recent call last): File "~/repos/fabric-testbed-api/cluster/main.py", line 75, in <module> raise ex File "~/repos/fabric-testbed-api/cluster/main.py", line 72, in <module> slice_id = fabric_slice.submit() File "~/.conda/envs/slate-fabrictestbed/lib/python3.9/site-packages/fabrictestbed_extensions/fablib/slice.py", line 1254, in submit return_status, slice_reservations = self.fablib_manager.get_slice_manager().create(slice_name=self.slice_name, File "~/.conda/envs/slate-fabrictestbed/lib/python3.9/site-packages/fabrictestbed/slice_manager/slice_manager.py", line 200, in create self.refresh_tokens() File "~/.conda/envs/slate-fabrictestbed/lib/python3.9/site-packages/fabrictestbed/slice_manager/slice_manager.py", line 160, in refresh_tokens raise SliceManagerException(tokens.get(CredmgrProxy.ERROR)) fabrictestbed.slice_manager.slice_manager.SliceManagerException: error: User is not a member of project: 'XXXX', refresh_token: abcdefg1234
August 19, 2022 at 11:57 am in reply to: Pip fabrictestbed-extensions 1.2.4 – “Exception ignored in” #2656Oops, missing
fablib.show_config()
for the first line above.January 18, 2022 at 5:15 pm in reply to: Slice stall on “Configuring” for MAX site via Python API #1244Hi Paul,
I was able to successfully lease a slice.
Thank you!
-AdamJanuary 17, 2022 at 2:11 pm in reply to: Slice stall on “Configuring” for MAX site via Python API #1240Hi Mert,
Apologies. Here is the Python I can use to reproduce the stall at “Configuring”:
`
from fabrictestbed.slice_editor import ComponentModelTypeslice_name = ‘KubernetesSlice13-adam’
site = ‘MAX’
node1_name = ‘Node1’
node2_name = ‘Node2′
network_service_name=’bridge1’
nic1_name = ‘node1-nic1’
nic2_name = ‘node2-nic1’
username = ‘centos’
image = ‘default_centos_8’
image_type = ‘qcow2′
cores = 4
ram = 20
disk = 100nvme_name=’nvme1’
nvme_model_type = ComponentModelType.NVME_P4510
`
`
from fabrictestbed.slice_editor import ExperimentTopology, Capacities, ComponentType, ComponentModelType, ServiceType
# Create topology
t = ExperimentTopology()# Add node
n1 = t.add_node(name=node1_name, site=site)# Set capacities
cap = Capacities()
cap.set_fields(core=cores, ram=ram, disk=disk)# Set Properties
n1.set_properties(capacities=cap, image_type=image_type, image_ref=image)# Add node
n2 = t.add_node(name=node2_name, site=site)# Set properties
n2.set_properties(capacities=cap, image_type=image_type, image_ref=image)# Shared Cards
n1.add_component(model_type=ComponentModelType.SharedNIC_ConnectX_6, name=nic1_name)
n2.add_component(model_type=ComponentModelType.SharedNIC_ConnectX_6, name=nic2_name)# Add the PCI NVMe device
n2.add_component(model_type=nvme_model_type, name=nvme_name)# L2Bridge Service
t.add_network_service(name=network_service_name, nstype=ServiceType.L2Bridge, interfaces=t.interface_list)# Generate Slice Graph
slice_graph = t.serialize()# Request slice from Orchestrator
return_status, slice_reservations = slice_manager.create(slice_name=slice_name,
slice_graph=slice_graph,
ssh_key=ssh_key_pub)if return_status == Status.OK:
slice_id = slice_reservations[0].get_slice_id()
print(“Submitted slice creation request. Slice ID: {}”.format(slice_id))
else:
print(f”Failure: {slice_reservations}”)
`
Cheers,
-AdamExtended answer: For my personal sanity I added a pattern resembling to
~/.ssh/config
file:### The External Fabric Bastion host Host fabric-bastion-host HostName bastion-1.fabric-testbed.net Port 22 User susanna_moser_0051524387 IdentityFile ~/work/id_rsa_fabric
This transforms ssh commands into
ssh -J fabric-bastion-host -i ~/.ssh/id_rsa centos@63.239.135.94
without the need for the ssh-agent voodoo.Try
eval
ssh-agent -s
followed byssh-add /path/to/<fabric key file>
. Then take your ssh command above, remove the first key option/value and run it again.- This reply was modified 3 years ago by ADAM GRIFFITH.
Hi Paul,
Unfortunately it does not. I’ll ping Mina and see if he can make it through /jupyter-examples/fabric_examples/complex_recipes/kubernetes-simple.ipynb.
Cheers,
-AdamLooks like things are back up.
This problem is present for me as well.
-
AuthorPosts