Slice activation and deactivation
Activating a slice
Slice activation presupposes a slice already exists, which you can learn how to do here.
It also implies that you have already created a Network-as-Code client
and identified your mobile network device.
So, after creating the desired slice according to the steps in the previous page,
simply use the activate()
method to activate the slice.
import network_as_code as nac
from network_as_code.models.device import DeviceIpv4Addr
from network_as_code.models.slice import(
NetworkIdentifier,
Slice,
SliceInfo,
AreaOfService,
Point,
Throughput
)
client = nac.NetworkAsCodeClient(...)
my_device = client.devices.get(...)
# First, create or get a slice
my_slice = client.slices.create(...)
# Get a slice by its ID
slice = client.slices.get(my_slice.name)
# Then, activate it
slice.activate()
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. Also, learn more about the slice life cycle, so your applications can react to different slice states, such as active, operating, pending, and so on.
Deactivating a slice
Use the following SDK snippet to deactivate slice.
import network_as_code as nac
from network_as_code.models.device import DeviceIpv4Addr
from network_as_code.models.slice import(
NetworkIdentifier,
Slice,
SliceInfo,
AreaOfService,
Point,
Throughput
)
my_device = client.devices.get(...)
# First, create or get a slice
my_slice = client.slices.create(...)
# Get a slice by its ID
slice = client.slices.get(my_slice.name)
# Then, deactivate it
slice.deactivate()
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.
Last updated on July 25, 2024