maasserver.models.macaddress

MACAddress model and friends.

Functions

SET_NULL(collector, field, sub_objs, using)
ensure_physical_interfaces_created() Utility function to create a PhysicalInterface for every MACAddress in the database that is not associated with any Interface.
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.
get_one(items) Assume there’s at most one item in items, and return it (or None).
raise_if_address_inside_dynamic_range(...[, ...]) Checks if the specified IP address, inside the specified fabric, is inside a MAAS-managed dynamic range.
update_mac_cluster_interfaces(ip, mac, cluster) Calculate and store which interface a MAC is attached to.
update_macs_cluster_interfaces(leases, cluster) Calculate and store which interface a set of MACs are attached to.

Classes

CleanSave Mixin for model classes.
DefaultMeta Base class for model Meta classes in the maasserver app.
ForeignKey(to[, to_field, rel_class, ...])
INTERFACE_TYPE The vocabulary of possible types for Interface.
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.
MACStaticIPAddressLink(*args, **kwargs) MACStaticIPAddressLink(id, created, updated, mac_address_id, ip_address_id, nic_alias)
ManyToManyField(to[, db_constraint])
Network(*args, **kwargs) Network(id, name, ip, netmask, default_gateway, dns_servers, vlan_tag, description)
NodeGroup(*args, **kwargs) NodeGroup(id, created, updated, cluster_name, name, status, api_token_id, api_key, dhcp_key, uuid, maas_url, default_disable_ipv4)
NodeGroupInterface(*args, **kwargs) Cluster interface.
StaticIPAddress(*args, **kwargs) StaticIPAddress(id, created, updated, ip, alloc_type, subnet_id, hostname, user_id)
TimestampedModel(*args, **kwargs) Abstract base model with creation/update timestamps.
attrgetter attrgetter(attr, ...) –> attrgetter object

Exceptions

StaticIPAddressConflict Raised when trying to allocate a static IP that doesn’t belong to the network the MAC address is connected to.
StaticIPAddressUnavailable Raised when a requested IP is not available.
maasserver.models.macaddress.find_cluster_interface_responsible_for_ip(cluster_interfaces, ip_address)[source]

Pick the cluster interface whose network contains ip_address.

Parameters:
  • cluster_interfaces – An iterable of NodeGroupInterface.
  • ip_address – An IPAddress.
Returns:

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.

Variables:
  • mac_address – The MAC address.
  • node – The Node related to this MACAddress.
  • networks – The networks related to this MACAddress.
get_networks()[source]

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

get_cluster_interfaces()[source]

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.

get_cluster_interface()[source]

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.

get_attached_clusters_with_static_ranges()[source]

Returns a list of cluster interfaces attached to this MAC address, where each cluster interface has a defined static range.

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

Shim to call claim_static_ips on the Interface object related to this MAC.

Updates DNS for the cluster related to this MAC.

set_static_ip(requested_address, user, fabric=None, update_host_maps=True)[source]

Assign a static (sticky) IP address to this MAC.

This is meant to be called on a device’s MAC address: the IP address can be anything. Only if the MAC is linked to a network will this method enforce that the IP address if part of the referenced network.

Calls update_host_maps() on the related Node in order to update any DHCP mappings.

Parameters:
  • requested_address – IP address to claim. Must not be in the dynamic range of any cluster interface.
  • user – User who will be given ownership of the created StaticIPAddress.
Returns:

A StaticIPAddress. If an IP address was already allocated, the function will return it rather than allocate a new one.

Raises:

StaticIPAddressForbidden if the requested_address is in a dynamic range.

Raises:

StaticIPAddressConflict if the MAC is connected to a cluster interface and the requested_address is not in the cluster’s network.

Raises:

StaticIPAddressUnavailable if the requested_address is already allocated.

MAAS logo

MAAS

Metal As A Service.



Related Topics

This Page