MACAddress model and friends.


SET_NULL(collector, field, sub_objs, using)
find_cluster_interface_responsible_for_ip(...) Pick the cluster interface whose network contains ip_address.
get_maas_logger([syslog_tag]) Return a MAAS logger that will log to syslog.
update_mac_cluster_interfaces(ip, mac, cluster) Calculate and store which interface a MAC is attached to.


BulkManager() A Manager which loads objects from the cache if it’s populated.
CleanSave Mixin for model classes.
DefaultMeta Base class for model Meta classes in the maasserver app.
ForeignKey(to[, to_field, rel_class, ...])
IPADDRESS_TYPE The vocabulary of possible types of StaticIPAddress.
IPAddress(addr[, version, flags]) An individual IPv4 or IPv6 address without a net mask or subnet prefix.
IPRange(start, end[, flags]) An arbitrary IPv4 or IPv6 address range.
MAC(value) A MAC address represented as a database value.
MACAddress(*args, **kwargs) A MACAddress represents a MAC address attached to a Node.
MACAddressField([verbose_name, name, ...]) Model field type: MAC address.
ManyToManyField(to[, db_constraint])
Network(*args, **kwargs) Network(id, name, ip, netmask, default_gateway, dns_servers, vlan_tag, description)
NodeGroupInterface(*args, **kwargs) Cluster interface.
TimestampedModel(*args, **kwargs) Abstract base model with creation/update timestamps.


StaticIPAddressOutOfRange Raised when a requested IP is not in an acceptable range.
StaticIPAddressTypeClash Raised when trying to allocate an IP for a MAC where one of another type already exists.
maasserver.models.macaddress.find_cluster_interface_responsible_for_ip(cluster_interfaces, ip_address)[source]

Pick the cluster interface whose network contains ip_address.

  • cluster_interfaces – An iterable of NodeGroupInterface.
  • ip_address – An IPAddress.

The cluster interface from cluster_interfaces whose subnet contains ip_address, or None.

class maasserver.models.macaddress.MACAddress(*args, **kwargs)[source]

Bases: maasserver.models.cleansave.CleanSave, maasserver.models.timestampedmodel.TimestampedModel

A MACAddress represents a MAC address attached to a Node.

  • mac_address – The MAC address.
  • node – The Node related to this MACAddress.
  • networks – The networks related to this MACAddress.

Return networks to which this MAC is connected, sorted by name.


Return all cluster interfaces to which this MAC connects.

This is at least its cluster_interface, if it is set. But if so, there may also be an IPv6 cluster interface attached to the same network interface.


Return the cluster interface for this MAC.

For an installable node, this is the cluster interface referenced by self.cluster_interface (populated during commissioning). For an non-installable node, if self.cluster_interface is not explicitly specified, we fall back to the cluster interface of the parent’s PXE MAC for the primary interface.

claim_static_ips(alloc_type=0, requested_address=None, user=None)[source]

Assign static IP addresses to this MAC.

Allocates one address per managed cluster interface connected to this MAC. Typically this will be either just one IPv4 address, or an IPv4 address and an IPv6 address.

It is the caller’s responsibility to update the DHCP server.

  • alloc_type – See StaticIPAddress.alloc_type. This parameter musn’t be IPADDRESS_TYPE.USER_RESERVED.
  • requested_address – Optional IP address to claim. Must be in the range defined on some cluster interface to which this MACAddress is related. If given, no allocations will be made on any other cluster interfaces the MAC may be connected to.
  • user – Optional User who will be given ownership of any `StaticIPAddress`es claimed.

A list of StaticIPAddress. Returns empty if the cluster_interface is not yet known, or the static_ip_range_low/high values values are not set on the cluster_interface. If an IP address was already allocated, the function will return it rather than allocate a new one.


StaticIPAddressExhaustion if there are not enough IPs left.


StaticIPAddressTypeClash if an IP already exists with a different type.


StaticIPAddressOutOfRange if the requested_address is not in the cluster interface’s defined range.


StaticIPAddressUnavailable if the requested_address is already allocated.

MAAS logo


Metal As A Service.

Related Topics

This Page