Skip to main content

Layer3 Subinterface

The Layer3Subinterface class manages Layer 3 subinterface objects in Palo Alto Networks' Strata Cloud Manager. Layer 3 subinterfaces operate at the network layer, supporting IP routing on VLAN-tagged traffic. They support static IP addressing or DHCP.

Class Overview

from scm.client import Scm

client = Scm(
client_id="your_client_id",
client_secret="your_client_secret",
tsg_id="your_tsg_id"
)

layer3_subinterfaces = client.layer3_subinterface
MethodDescriptionParametersReturn Type
create()Creates a new Layer 3 subinterfacedata: Dict[str, Any]Layer3SubinterfaceResponseModel
get()Retrieves a Layer 3 subinterface by IDobject_id: strLayer3SubinterfaceResponseModel
update()Updates an existing Layer 3 subinterfacesubinterface: Layer3SubinterfaceUpdateModelLayer3SubinterfaceResponseModel
list()Lists Layer 3 subinterfaces with optional filteringfolder, snippet, device, plus filtersList[Layer3SubinterfaceResponseModel]
fetch()Fetches a single Layer 3 subinterface by name within a containername: str, folder, snippet, deviceLayer3SubinterfaceResponseModel
delete()Deletes a Layer 3 subinterface by IDobject_id: strNone

Layer3 Subinterface Model Attributes

AttributeTypeRequiredDefaultDescription
namestrYesNoneInterface name (e.g., "ethernet1/1.100")
idUUIDYes*NoneUnique identifier (*response/update only)
tagstrYesNoneVLAN tag (1-4096)
commentstrNoNoneDescription. Max 1023 chars
ipList[StaticIp]No**NoneStatic IP addresses
dhcp_clientDhcpClientNo**NoneDHCP client configuration
mtuintNo1500MTU (576-9216)
interface_management_profilestrNoNoneManagement profile name. Max 31 chars
arpList[ArpEntry]NoNoneStatic ARP entries
ddns_configDdnsConfigNoNoneDynamic DNS configuration
folderstrNo***NoneFolder location. Max 64 chars
snippetstrNo***NoneSnippet location. Max 64 chars
devicestrNo***NoneDevice location. Max 64 chars

* Only required for update and response models ** Only one IP mode (static or DHCP) can be configured *** Exactly one container must be provided for create operations

IP Addressing Modes

Static IP

subinterface_data = {
"name": "ethernet1/1.100",
"tag": "100",
"ip": [{"name": "192.168.100.1/24"}],
"mtu": 1500,
"folder": "Interfaces"
}

DHCP

subinterface_data = {
"name": "ethernet1/1.100",
"tag": "100",
"dhcp_client": {
"enable": True,
"create_default_route": True,
"default_route_metric": 10
},
"folder": "Interfaces"
}

Exceptions

ExceptionHTTP CodeDescription
InvalidObjectError400Invalid data or parameters
MissingQueryParameterError400Missing required parameters
ObjectNotPresentError404Interface not found
AuthenticationError401Authentication failed
ServerError500Internal server error

Methods

List Layer3 Subinterfaces

# List all Layer 3 subinterfaces
subinterfaces = client.layer3_subinterface.list(folder="Interfaces")

for sub in subinterfaces:
print(f"Name: {sub.name}, VLAN: {sub.tag}")
if sub.ip:
for ip in sub.ip:
print(f" IP: {ip.name}")

# Filter by VLAN tag
vlan100 = client.layer3_subinterface.list(folder="Interfaces", tag="100")

# Filter by MTU
jumbo = client.layer3_subinterface.list(folder="Interfaces", mtu=9000)

Fetch a Layer3 Subinterface

# Fetch by name
subinterface = client.layer3_subinterface.fetch(
name="ethernet1/1.100",
folder="Interfaces"
)
print(f"Found: {subinterface.name}, VLAN: {subinterface.tag}")

# Get by ID
subinterface_by_id = client.layer3_subinterface.get(subinterface.id)

Create a Layer3 Subinterface

# Create with static IP
static_subinterface = {
"name": "ethernet1/1.100",
"tag": "100",
"comment": "VLAN 100 Gateway",
"ip": [{"name": "192.168.100.1/24"}],
"mtu": 1500,
"interface_management_profile": "allow-ping",
"arp": [
{"name": "192.168.100.10", "hw_address": "00:11:22:33:44:55"}
],
"folder": "Interfaces"
}

result = client.layer3_subinterface.create(static_subinterface)
print(f"Created: {result.id}")

# Create with DHCP
dhcp_subinterface = {
"name": "ethernet1/2.200",
"tag": "200",
"dhcp_client": {
"enable": True,
"create_default_route": False
},
"folder": "Interfaces"
}

result = client.layer3_subinterface.create(dhcp_subinterface)

Update a Layer3 Subinterface

existing = client.layer3_subinterface.fetch(
name="ethernet1/1.100",
folder="Interfaces"
)

# Update MTU
existing.mtu = 9000

# Add static ARP entry
if existing.arp is None:
existing.arp = []
existing.arp.append({"name": "192.168.100.20", "hw_address": "00:11:22:33:44:66"})

updated = client.layer3_subinterface.update(existing)

Delete a Layer3 Subinterface

client.layer3_subinterface.delete("123e4567-e89b-12d3-a456-426655440000")

Use Cases

Managing Configuration Changes

result = client.commit(
folders=["Interfaces"],
description="Updated Layer 3 subinterfaces",
sync=True
)

Error Handling

from scm.exceptions import InvalidObjectError

try:
subinterface = client.layer3_subinterface.create({
"name": "ethernet1/1.100",
"tag": "100",
"ip": [{"name": "192.168.100.1/24"}],
"dhcp_client": {"enable": True}, # Error: both modes
"folder": "Interfaces"
})
except InvalidObjectError as e:
print(f"Invalid configuration: {e.message}")