Slice activation and deactivation
Activating a slice
Slice activation presupposes a slice already exists.
So, after creating the desired slice according to the steps in the previous page,
simply use the client.slices.activate()
method to activate the slice.
from network_as_code.client import NetworkAsCodeClient
device = client.devices.get(...)
slice = client.slices.create(...)
# Activate the slice by its name
slice.activate(slice_id="<replace-with-slice-name>")
NOTE: A slice might take a significant amount of time (minutes) to be set up. So, you can configure a web server to receive to receive slice-status notifications. This will allow you to know when a slice is ready to be configured as desired.
Deactivating a slice
Use the following SDK snippet to deactivate slice.
from network_as_code.client import NetworkAsCodeClient
device = client.devices.get(...)
slice = client.slices.create(...)
slice.activate(...)
# Deactivate the slice by its name
slice.deactivate(slice_id="<replace-with-slice-name>")
Keep in mind: Slices need to be deactivated before you delete them. Therefore, it's not possible to delete an active slice (with an
OPERATING
status). Check how you can delete a slice.
Slice activation and deactivation parameter
The slice.activate()
and slice.deactivate()
methods require the following parameter:
Parameter | Description |
---|---|
slice_id | Choose a name to identify the slice (mandatory). |