Skip to main content

Loopback Interface

The LoopbackInterface class manages loopback interface objects in Palo Alto Networks' Strata Cloud Manager. Loopback interfaces are virtual interfaces that are always up and can be used for management access, BGP peering, and other services that require a stable IP address not tied to a physical interface.

Class Overview

from scm.client import Scm

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

loopback_interfaces = client.loopback_interface
MethodDescriptionParametersReturn Type
create()Creates a new loopback interfacedata: Dict[str, Any]LoopbackInterfaceResponseModel
get()Retrieves a loopback interface by IDobject_id: strLoopbackInterfaceResponseModel
update()Updates an existing loopback interfaceloopback: LoopbackInterfaceUpdateModelLoopbackInterfaceResponseModel
list()Lists loopback interfaces with optional filteringfolder, snippet, device, plus filtersList[LoopbackInterfaceResponseModel]
fetch()Fetches a single loopback interface by name within a containername: str, folder, snippet, deviceLoopbackInterfaceResponseModel
delete()Deletes a loopback interface by IDobject_id: strNone

Loopback Interface Model Attributes

AttributeTypeRequiredDefaultDescription
namestrYesNoneInterface name (e.g., "loopback.1")
idUUIDYes*NoneUnique identifier (*response/update only)
commentstrNoNoneDescription. Max 1023 chars
ipList[str]NoNoneList of IPv4 addresses (e.g., ["10.0.0.1/32"])
ipv6Ipv6ConfigNoNoneIPv6 configuration
mtuintNo1500MTU (576-9216)
interface_management_profilestrNoNoneManagement profile name. Max 31 chars
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 ** Exactly one container must be provided for create operations

Exceptions

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

Methods

List Loopback Interfaces

# List all loopbacks
loopbacks = client.loopback_interface.list(folder="Interfaces")

for lb in loopbacks:
print(f"Name: {lb.name}")
if lb.ip:
print(f" IPv4: {', '.join(lb.ip)}")

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

Fetch a Loopback Interface

# Fetch by name
loopback = client.loopback_interface.fetch(
name="loopback.1",
folder="Interfaces"
)
print(f"Found: {loopback.name}, IP: {loopback.ip}")

# Get by ID
loopback_by_id = client.loopback_interface.get(loopback.id)

Create a Loopback Interface

# Create loopback with IPv4
loopback_data = {
"name": "loopback.1",
"comment": "Management loopback",
"ip": ["10.0.0.1/32"],
"interface_management_profile": "allow-ping",
"folder": "Interfaces"
}

result = client.loopback_interface.create(loopback_data)
print(f"Created loopback: {result.id}")

# Create loopback with IPv6
loopback_ipv6 = {
"name": "loopback.2",
"ip": ["192.168.1.1/32"],
"ipv6": {
"enabled": True,
"address": [{"name": "2001:db8::1/128"}]
},
"folder": "Interfaces"
}

result = client.loopback_interface.create(loopback_ipv6)

Update a Loopback Interface

existing = client.loopback_interface.fetch(name="loopback.1", folder="Interfaces")

# Add additional IP
if existing.ip:
existing.ip.append("10.0.0.2/32")
else:
existing.ip = ["10.0.0.2/32"]

updated = client.loopback_interface.update(existing)

Delete a Loopback Interface

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

Use Cases

Managing Configuration Changes

result = client.commit(
folders=["Interfaces"],
description="Updated loopback interfaces",
sync=True
)

Error Handling

from scm.exceptions import InvalidObjectError, ObjectNotPresentError

try:
loopback = client.loopback_interface.fetch(
name="nonexistent",
folder="Interfaces"
)
except ObjectNotPresentError as e:
print(f"Interface not found: {e.message}")