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 activate() method to activate the slice.

from network_as_code.client import NetworkAsCodeClient
 
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, 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.

Deactivating a slice

Use the following SDK snippet to deactivate slice.

from network_as_code.client import NetworkAsCodeClient
 
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 May 21, 2024