CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-nautobot

Source of truth and network automation platform for network infrastructure management.

Pending
Overview
Eval results
Files

cloud.mddocs/

Cloud Management

Cloud infrastructure management including cloud accounts, resource types, networks, and services. Provides comprehensive modeling of cloud provider resources with hierarchical organization and integration with IPAM systems.

Capabilities

Cloud Account Management

Manage cloud provider accounts with authentication and configuration.

class CloudAccount:
    """
    Cloud provider account management.
    
    Attributes:
        name (str): The name of the cloud account (unique, max 255 chars)
        description (str, optional): Description of the account (max 255 chars)
        account_number (str): The account identifier (max 255 chars)
        provider (ForeignKey): Cloud provider (dcim.Manufacturer)
        secrets_group (ForeignKey, optional): Associated secrets group (extras.SecretsGroup)
    """
    
    @property
    def display(self):
        """Returns formatted string: {provider}: {name} - {account_number}"""

Cloud Resource Type Management

Define and manage cloud resource types with schema validation.

class CloudResourceType:
    """
    Cloud resource type definitions with JSON schema validation.
    
    Attributes:
        name (str): Type of cloud objects (unique, max 255 chars)
        description (str, optional): Description of the resource type (max 255 chars)
        provider (ForeignKey): Cloud provider (dcim.Manufacturer)
        config_schema (JSONField, optional): JSON schema for validation
        content_types (ManyToManyField): Applicable model types
    """
    
    @property
    def display(self):
        """Returns formatted string: {provider}: {name}"""

class CloudResourceTypeMixin:
    """
    Abstract mixin for models that use CloudResourceType.
    
    Attributes:
        cloud_resource_type (ForeignKey): Associated resource type
        extra_config (JSONField, optional): Additional configuration data
    """
    
    def clean(self):
        """Validates extra_config against cloud_resource_type.config_schema using JSON Schema Draft 7."""

Cloud Network Management

Hierarchical cloud network management with IPAM integration.

class CloudNetwork:
    """
    Cloud network management with hierarchical organization.
    
    Inherits: CloudResourceTypeMixin, PrimaryModel
    
    Attributes:
        name (str): Network name (unique, max 255 chars)
        description (str, optional): Network description (max 255 chars)
        cloud_account (ForeignKey): Associated cloud account
        parent (ForeignKey, optional): Parent network (max 2 levels deep)
        prefixes (ManyToManyField): Associated IPAM prefixes (through CloudNetworkPrefixAssignment)
    """
    
    def clean(self):
        """
        Validates network hierarchy:
        - Parent cannot have a parent (no grandparent relationships)
        - Cannot be its own parent
        """

class CloudNetworkPrefixAssignment:
    """
    Through model for CloudNetwork ↔ Prefix relationship.
    
    Attributes:
        cloud_network (ForeignKey): Associated cloud network
        prefix (ForeignKey): Associated IPAM prefix
    """

Cloud Service Management

Cloud service management with network associations.

class CloudService:
    """
    Cloud service management with network associations.
    
    Inherits: CloudResourceTypeMixin, PrimaryModel
    
    Attributes:
        name (str): Service name (unique, max 255 chars)
        description (str, optional): Service description (max 255 chars)
        cloud_account (ForeignKey, optional): Associated cloud account
        cloud_networks (ManyToManyField): Associated networks (through CloudServiceNetworkAssignment)
    """

class CloudServiceNetworkAssignment:
    """
    Through model for CloudService ↔ CloudNetwork relationship.
    
    Attributes:
        cloud_network (ForeignKey): Associated cloud network
        cloud_service (ForeignKey): Associated cloud service
    """

API Serializers

REST API serializers for cloud resources.

class CloudAccountSerializer:
    """Serializer for CloudAccount with tagging support."""

class CloudResourceTypeSerializer:
    """Serializer for CloudResourceType with ContentType fields."""

class CloudNetworkSerializer:
    """Serializer for CloudNetwork with tagging and hierarchical support."""

class CloudNetworkPrefixAssignmentSerializer:
    """Serializer for CloudNetwork-Prefix associations."""

class CloudServiceSerializer:
    """Serializer for CloudService with tagging support."""

class CloudServiceNetworkAssignmentSerializer:
    """Serializer for CloudService-Network associations."""

API ViewSets

REST API viewsets for cloud resource management.

class CloudAccountViewSet:
    """ViewSet for CloudAccount CRUD operations with filtering."""

class CloudResourceTypeViewSet:
    """ViewSet for CloudResourceType CRUD operations with filtering."""

class CloudNetworkViewSet:
    """ViewSet for CloudNetwork CRUD operations with filtering."""

class CloudNetworkPrefixAssignmentViewSet:
    """ViewSet for CloudNetwork-Prefix assignment operations."""

class CloudServiceViewSet:
    """ViewSet for CloudService CRUD operations with filtering."""

class CloudServiceNetworkAssignmentViewSet:
    """ViewSet for CloudService-Network assignment operations."""

Usage Examples

Basic Cloud Account Setup

from nautobot.cloud.models import CloudAccount, CloudResourceType
from nautobot.dcim.models import Manufacturer
from nautobot.extras.models import Status

# Create a cloud provider
aws = Manufacturer.objects.create(name="AWS")

# Create a cloud account
account = CloudAccount.objects.create(
    name="Production AWS Account",
    description="Main production AWS environment",
    account_number="123456789012",
    provider=aws
)

# Create resource types for this provider
vpc_type = CloudResourceType.objects.create(
    name="VPC",
    description="Virtual Private Cloud",
    provider=aws,
    config_schema={
        "type": "object",
        "properties": {
            "region": {"type": "string"},
            "cidr_block": {"type": "string"}
        },
        "required": ["region", "cidr_block"]
    }
)

Hierarchical Network Management

from nautobot.cloud.models import CloudNetwork
from nautobot.ipam.models import Prefix, Namespace

# Create a parent network (VPC)
namespace = Namespace.objects.get(name="Global")
prefix = Prefix.objects.create(
    prefix="10.0.0.0/16",
    namespace=namespace,
    status=Status.objects.get(name="Active")
)

vpc = CloudNetwork.objects.create(
    name="prod-vpc-01",
    description="Production VPC",
    cloud_account=account,
    cloud_resource_type=vpc_type,
    extra_config={
        "region": "us-east-1",
        "cidr_block": "10.0.0.0/16"
    }
)

# Associate prefix with the network
from nautobot.cloud.models import CloudNetworkPrefixAssignment
CloudNetworkPrefixAssignment.objects.create(
    cloud_network=vpc,
    prefix=prefix
)

# Create a subnet (child network)
subnet_prefix = Prefix.objects.create(
    prefix="10.0.1.0/24",
    namespace=namespace,
    status=Status.objects.get(name="Active"),
    parent=prefix
)

subnet = CloudNetwork.objects.create(
    name="prod-subnet-01",
    description="Production subnet 1",
    cloud_account=account,
    parent=vpc,
    cloud_resource_type=CloudResourceType.objects.create(
        name="Subnet",
        provider=aws
    )
)

CloudNetworkPrefixAssignment.objects.create(
    cloud_network=subnet,
    prefix=subnet_prefix
)

Cloud Service Configuration

from nautobot.cloud.models import CloudService, CloudServiceNetworkAssignment

# Create a cloud service
rds_type = CloudResourceType.objects.create(
    name="RDS Database",
    description="Relational Database Service",
    provider=aws,
    config_schema={
        "type": "object",
        "properties": {
            "engine": {"type": "string"},
            "instance_class": {"type": "string"},
            "allocated_storage": {"type": "integer"}
        },
        "required": ["engine", "instance_class"]
    }
)

database = CloudService.objects.create(
    name="prod-db-01",
    description="Production database server",
    cloud_account=account,
    cloud_resource_type=rds_type,
    extra_config={
        "engine": "postgresql",
        "instance_class": "db.t3.medium",
        "allocated_storage": 100
    }
)

# Associate service with networks
CloudServiceNetworkAssignment.objects.create(
    cloud_service=database,
    cloud_network=subnet
)

API Usage

from nautobot.cloud.api.serializers import CloudAccountSerializer, CloudNetworkSerializer
from nautobot.cloud.api.views import CloudAccountViewSet

# Serialize cloud account data
serializer = CloudAccountSerializer(account)
data = serializer.data

# Query cloud networks via API
networks = CloudNetwork.objects.filter(cloud_account=account)
network_serializer = CloudNetworkSerializer(networks, many=True)
network_data = network_serializer.data

Filtering and Search

from nautobot.cloud.filters import CloudNetworkFilterSet

# Filter networks by provider
aws_networks = CloudNetwork.objects.filter(
    cloud_account__provider__name="AWS"
)

# Search across multiple fields
search_results = CloudNetwork.objects.filter(
    name__icontains="prod"
).filter(
    description__icontains="vpc"
)

# Filter by resource type
vpc_networks = CloudNetwork.objects.filter(
    cloud_resource_type__name="VPC"
)

API Endpoints

The cloud module exposes the following REST API endpoints:

  • /api/cloud/cloud-accounts/ - Cloud account management
  • /api/cloud/cloud-networks/ - Network management
  • /api/cloud/cloud-network-prefix-assignments/ - Network-prefix associations
  • /api/cloud/cloud-resource-types/ - Resource type definitions
  • /api/cloud/cloud-services/ - Service management
  • /api/cloud/cloud-service-network-assignments/ - Service-network associations

Error Handling

Common validation patterns for cloud resources:

from django.core.exceptions import ValidationError
from nautobot.cloud.models import CloudNetwork

try:
    # Attempt to create invalid hierarchy (3 levels deep)
    grandchild = CloudNetwork.objects.create(
        name="invalid-network",
        cloud_account=account,
        parent=subnet  # subnet already has a parent (vpc)
    )
except ValidationError as e:
    # Handle hierarchy validation error
    print(f"Validation error: {e}")

try:
    # Invalid JSON schema validation
    network = CloudNetwork(
        name="test-network",
        cloud_account=account,
        cloud_resource_type=vpc_type,
        extra_config={
            "region": "us-east-1"
            # Missing required "cidr_block" field
        }
    )
    network.full_clean()
except ValidationError as e:
    # Handle schema validation error
    print(f"Schema validation error: {e}")

Install with Tessl CLI

npx tessl i tessl/pypi-nautobot@2.4.1

docs

circuits.md

cloud.md

core-framework.md

dcim.md

extensibility.md

index.md

ipam.md

tenancy-users.md

virtualization-cloud.md

wireless.md

tile.json