maasserver.models

Model export and helpers for maasserver.

Functions

create_user(sender, instance, created, **kwargs)
get_callable(*args) Convert a string version of a function name to the callable object.
get_resolver(*args)
get_resource_uri_template(self) URI template processor.
get_script_prefix() Returns the currently active script prefix.
ignore_unused(*args) Suppress warnings about unused variables.

Classes

Bcache(*args, **kwargs) A Bcache.
BlockDevice(*args, **kwargs) A block device attached to a node.
BondInterface(*args, **kwargs) BondInterface(id, created, updated, name, type, vlan_id, mac_id, ipv4_params, ipv6_params, params, tags)
BootResource(*args, **kwargs) Boot resource.
BootResourceFile(*args, **kwargs) File associated with a BootResourceSet.
BootResourceSet(*args, **kwargs) Set of files that make up a BootResource.
BootSource(*args, **kwargs) A source for boot resources.
BootSourceCache(*args, **kwargs) A cache of an image provided in boot source.
BootSourceSelection(*args, **kwargs) A set of selections for a single BootSource.
CacheSet(*args, **kwargs) A Bcache cache set.
CandidateName(*args, **kwargs) A CandidateName represents a name we can use to name something.
ComponentError(*args, **kwargs) Error state of a major component of the system.
Config(*args, **kwargs) Configuration settings item.
DHCPLease(*args, **kwargs) A known mapping of an IP address to a MAC address.
Device(*args, **kwargs) A non-installable node.
DownloadProgress(*args, **kwargs) Progress report from a cluster for one of its boot-image downloads.
Event(*args, **kwargs) An Event represents a MAAS event.
EventType(*args, **kwargs) A type for events.
Fabric(*args, **kwargs) A Fabric.
FileStorage(*args, **kwargs) A simple file storage keyed on file name.
Filesystem(*args, **kwargs) A filesystem on partition or a block device.
FilesystemGroup(*args, **kwargs) A filesystem group.
HandlerDocumentation(handler)
Interface(*args, **kwargs) Interface(id, created, updated, name, type, vlan_id, mac_id, ipv4_params, ipv6_params, params, tags)
LargeFile(*args, **kwargs) Files that are stored in the large object storage.
LicenseKey(*args, **kwargs) Available license key for osystem and distro_series combo.
MAASAuthorizationBackend
MACAddress(*args, **kwargs) A MACAddress represents a MAC address attached to a Node.
MACStaticIPAddressLink(*args, **kwargs) MACStaticIPAddressLink(id, created, updated, mac_address_id, ip_address_id, nic_alias)
ModelBackend Authenticates against settings.AUTH_USER_MODEL.
NODE_PERMISSION Permissions relating to nodes.
Network(*args, **kwargs) Network(id, name, ip, netmask, default_gateway, dns_servers, vlan_tag, description)
Node(*args, **kwargs) A Node represents a physical machine used by the MAAS Server.
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.
Partition(*args, **kwargs) A partition in a partition table.
PartitionTable(*args, **kwargs) A partition table on a block device.
PhysicalBlockDevice(*args, **kwargs) A physical block device attached to a node.
PhysicalInterface(*args, **kwargs) PhysicalInterface(id, created, updated, name, type, vlan_id, mac_id, ipv4_params, ipv6_params, params, tags)
RAID(*args, **kwargs) A RAID.
SSHKey(*args, **kwargs) An SSHKey represents a user public SSH key.
SSLKey(*args, **kwargs) An SSLKey represents a user SSL key.
Space(*args, **kwargs) A Space.
StaticIPAddress(*args, **kwargs) StaticIPAddress(id, created, updated, ip, alloc_type, subnet_id, hostname, user_id)
Subnet(*args, **kwargs) Subnet(id, created, updated, name, vlan_id, space_id, cidr, gateway_ip, dns_servers)
Tag(*args, **kwargs) A Tag is a label applied to a Node.
User(*args, **kwargs) Users within the Django authentication system are represented by this model.
UserProfile(*args, **kwargs) A User profile to store MAAS specific methods and fields.
VLAN(*args, **kwargs) A VLAN.
VLANInterface(*args, **kwargs) VLANInterface(id, created, updated, name, type, vlan_id, mac_id, ipv4_params, ipv6_params, params, tags)
VirtualBlockDevice(*args, **kwargs) A virtual block device attached to a node.
VolumeGroup(*args, **kwargs) A volume group.
Zone(*args, **kwargs) A Zone is an entity used to logically group nodes together.
class maasserver.models.Bcache(*args, **kwargs)

Bases: maasserver.models.filesystemgroup.FilesystemGroup

A Bcache.

class maasserver.models.BlockDevice(*args, **kwargs)

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

A block device attached to a node.

actual_instance

Return the instance as its correct type.

By default all references from Django will be to BlockDevice, when the native type PhysicalBlockDevice or VirtualBlockDevice is needed use this property to get its actual instance.

add_tag(tag)

Add tag to block device.

delete()

Delete the block device.

If this block device is part of a filesystem group then it cannot be deleted.

filesystem

Return the filesystem that is placed on this block device.

get_name()

Return the name.

This exists so VirtualBlockDevice can override this method.

get_node()

Return the name.

get_partitiontable()

Returns this device’s partition table (or None, if none exists.

remove_tag(tag)

Remove tag from block device.

class maasserver.models.BootResource(*args, **kwargs)

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

Boot resource.

Each BootResource represents a os/series combination or custom uploaded image that maps to a specific architecture that a node can use to commission or install.

BootResource can have multiple BootResourceSet corresponding to different versions of this BootResource. When a node selects this BootResource the newest BootResourceSet is used to deploy to the node.

Variables:
  • rtype – Type of BootResource. See the vocabulary BOOT_RESOURCE_TYPE.
  • name – Name of the BootResource. If its BOOT_RESOURCE_TYPE.UPLOADED then name is used to reference this image. If its BOOT_RESOURCE_TYPE.SYCNED or BOOT_RESOURCE_TYPE.GENERATED then its in the format of os/series.
  • architecture – Architecture of the BootResource. It must be in the format arch/subarch.
  • extra – Extra information about the file. This is only used for synced Ubuntu images.
clean()

Validate the model.

Checks that the name is in a valid format, for its type.

display_rtype

Return rtype text as displayed to the user.

get_latest_complete_set()

Return latest BootResourceSet where all BootResouceFile‘s are complete.

get_latest_set()

Return latest BootResourceSet.

get_next_version_name()

Return the version a BootResourceSet should use when adding to this resource.

The version naming is specific to how the resource sets will be sorted by simplestreams. The version name is YYYYmmdd, with an optional revision index. (e.g. 20140822.1)

This method gets the current date, and checks if a revision already exists in the database. If it doesn’t then just the current date is returned. If it does exists then the next revision in the set for that date will be returned.

Returns:Name of version to use for a new set on this BootResource.
Return type:string
supports_subarch(subarch)

Return True if the resource supports the given subarch.

class maasserver.models.BootResourceFile(*args, **kwargs)

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

File associated with a BootResourceSet.

Each BootResourceSet contains a set of files. For user uploaded boot resources this is only one file. For synced and generated resources this can be multiple files.

Variables:
  • resource_setBootResourceSet file belongs to. When BootResourceSet is deleted, this BootResourceFile will be deleted.
  • largefile – Actual file information and data. See LargeFile.
  • filename – Name of the file.
  • filetype – Type of the file. See the vocabulary BOOT_RESOURCE_FILE_TYPE.
  • extra – Extra information about the file. This is only used for synced Ubuntu images.
class maasserver.models.BootResourceSet(*args, **kwargs)

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

Set of files that make up a BootResource. Each BootResource can have a different set of files. As new versions of the BootResource is synced, generated, or uploaded then new sets are created.

A booting node will always select the newest BootResourceSet for the selected BootResource. Older booted nodes might be using past versions. Older BootResourceSet are removed once zero nodes are referencing them.

Each BootResourceSet contains a set of files. For user uploaded boot resources this is only one file. For synced and generated resources this can be multiple files.

Variables:
  • resourceBootResource set belongs to. When BootResource is deleted, this BootResourceSet will be deleted. Along with all associated files.
  • version – Version name for the set. This normally is in the format of YYYYmmdd.r.
  • label – Label for this version. For GENERATED and UPLOADED its always generated or uploaded respectively. For SYNCED its depends on the source, either daily or release.
commissionable

True if BootResourceSet supports the ability to commission a node.

complete

True if all files in the set are complete.

installable

True if BootResourceSet supports the ability to install to a node.

progress

Percentage complete for all files in the set.

size

Amount of space this set currently consumes.

total_size

Total amount of space this set will consume.

xinstallable

True if BootResourceSet supports the ability to xinstall to a node.

class maasserver.models.BootSource(*args, **kwargs)

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

A source for boot resources.

compare_dict_without_selections(other)

Compare this BootSource, as a dict, to another, as a dict.

Only the keys url and keyring_data are relevant.

to_dict()

Return the current BootSource as a dict.

The dict will contain the details of the BootSource and all its BootSourceSelection items.

If the BootSource has keyring_data, that data will be returned base64 encoded. Otherwise the BootSource will have a value in its keyring_filename field, and that file’s contents will be base64 encoded and returned.

to_dict_without_selections()

Return the current BootSource as a dict, without including any BootSourceSelection items.

The dict will contain the details of the BootSource.

If the BootSource has keyring_data, that data will be returned base64 encoded. Otherwise the BootSource will have a value in its keyring_filename field, and that file’s contents will be base64 encoded and returned.

class maasserver.models.BootSourceCache(*args, **kwargs)

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

A cache of an image provided in boot source.

class maasserver.models.BootSourceSelection(*args, **kwargs)

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

A set of selections for a single BootSource.

to_dict()

Return the current BootSourceSelection as a dict.

class maasserver.models.CacheSet(*args, **kwargs)

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

A Bcache cache set.

get_device()

Return the device that is apart of this cache set.

Returns either a PhysicalBlockDevice, VirtualBlockDevice, or Partition.

get_filesystem()

Return the filesystem for this cache set.

get_name()

Return the name of the node.

get_node()

Return the node of the cache set.

name

Return the name of the cache set.

class maasserver.models.ComponentError(*args, **kwargs)

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

Error state of a major component of the system.

class maasserver.models.Config(*args, **kwargs)

Bases: django.db.models.base.Model

Configuration settings item.

Variables:
  • name – The name of the configuration option.
  • value – The configuration value.
class maasserver.models.Device(*args, **kwargs)

Bases: maasserver.models.node.Node

A non-installable node.

class maasserver.models.DHCPLease(*args, **kwargs)

Bases: maasserver.models.cleansave.CleanSave, django.db.models.base.Model

A known mapping of an IP address to a MAC address.

These correspond to the latest-known DHCP leases handed out to nodes (or potential nodes – they may not have been enlisted yet!) by the node group worker’s DHCP server.

class maasserver.models.DownloadProgress(*args, **kwargs)

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

Progress report from a cluster for one of its boot-image downloads.

Each download on each cluster controller gets its own record. The bytes_downloaded and last-change timestamp are updated with each progress report for that download. The creation timestamp reflects the time of the download’s first progress report.

A cluster may download a file of the same name as a file it has downloaded once already. The new download will have a new record.

The download is complete when bytes_downloaded equals size, provided there is no error. A download with a non-blank error is considered to have failed.

Variables:
  • nodegroup – The cluster whose controller is doing this download.
  • filename – Name of the file being downloaded.
  • size – Size of the file, in bytes. This may not be known in advance, but must be set at some point for any successful download.
  • bytes_downloaded – Number of bytes that have been downloaded.
  • error – Failure message.
class maasserver.models.Event(*args, **kwargs)

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

An Event represents a MAAS event.

Variables:
  • type – The event’s type.
  • node – The node of the event.
  • description – A free-form description of the event.
class maasserver.models.FileStorage(*args, **kwargs)

Bases: maasserver.models.cleansave.CleanSave, django.db.models.base.Model

A simple file storage keyed on file name.

Variables:
  • filename – A file name to use for the data being stored.
  • owner – This file’s owner..
  • content – The file’s actual data.
anon_resource_uri

URI where the content of the file can be retrieved anonymously.

class maasserver.models.Filesystem(*args, **kwargs)

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

A filesystem on partition or a block device.

Variables:
  • uuid – UUID of the filesystem.
  • fstype – Type of filesystem. This can even be filesystems that cannot be mounted directly, e.g. LVM.
  • partitionPartition this filesystem is on. If empty the filesystem must be directly on a BlockDevice.
  • block_deviceBlockDevice this filesystem is on. If empty the filesystem must be on a Partition.
  • filesystem_groupFilesystemGroup this filesystem belongs to.
  • create_params – Parameters that can be passed during the mkfs command when the filesystem is created.
  • mount_point – Path to where this filesystem is mounted on the deployed operating system.
  • mount_params – Parameters that are used to mount this filesystem on the deployed operating system.
get_block_size()

Block size of partition table.

get_node()

Node this filesystem belongs to.

get_parent()

Return linked BlockDevice or linked Partition.

get_size()

Size of filesystem.

class maasserver.models.FilesystemGroup(*args, **kwargs)

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

A filesystem group. Contains a set of filesystems that create a virtual block device. E.g. LVM Volume Group.

Variables:
  • uuid – UUID of the filesystem group.
  • group_type – Type of filesystem group.
  • name – Name of the filesytem group.
  • create_params – Parameters that can be passed during the create command when the filesystem group is created.
delete(force=False)

Delete from the database.

Parameters:force – Delete any related object that prevents this object from being deleted.
get_bcache_backing_block_device()

Return the block_device that is the backing device for the Bcache.

This will return the block device even if the backing is a partition.

get_bcache_backing_filesystem()

Return the filesystem that is the backing device for the Bcache.

get_bcache_size()

Size of this Bcache.

Calculated based on the size of the backing device. The linked VirtualBlockDevice should calculate its size from this filesystem group.

Note: Should only be called when the group_type is BCACHE.

get_lvm_allocated_size(skip_volumes=[])

Returns the space already allocated to virtual block devices.

Calculated from the total size of all virtual block devices in this group.

get_lvm_free_space(skip_volumes=[])

Returns the total unallocated space on this FilesystemGroup

get_lvm_size()

Size of this LVM volume group.

Calculated from the total size of all filesystems in this group. Its not calculated from its virtual_block_device size.

Note: Should only be called when the group_type is LVM_VG.

get_name_prefix()

Return the prefix that should be used when setting the name of this FilesystemGroup.

get_nice_name()

Return the nice name for the filesystem group.

This is used when showing error or log messages.

get_node()

Node this filesystem group belongs to.

get_raid_size()

Size of this RAID.

Calculated based on the RAID type and how output size based on that type. The size will be calculated using the smallest size filesystem attached to this RAID. The linked VirtualBlockDevice should calculate its size from this filesystem group.

Note: Should only be called when the group_type is in
FILESYSTEM_GROUP_RAID_TYPES.
get_size()

Size of this filesystem group.

Calculated from the total size of all filesystems in this group. Its not calculated from its virtual_block_device size. The linked VirtualBlockDevice should calculate its size from this filesystem group.

get_smallest_filesystem_size()

Return the smallest filesystem size.

get_virtual_block_device_block_size()

Return the block size that should be used on a created VirtualBlockDevice for this filesystem group.

is_bcache()

Return True if group_type is BCACHE type.

is_lvm()

Return True if group_type is LVM_VG type.

is_raid()

Return True if group_type is a RAID type.

virtual_device

Return the linked VirtualBlockDevice.

This should never be called when the group_type is LVM_VG. virtual_devices should be used in that case, since LVM_VG supports multiple `VirtualBlockDevice`s.

class maasserver.models.Interface(*args, **kwargs)

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

Interface(id, created, updated, name, type, vlan_id, mac_id, ipv4_params, ipv6_params, params, tags)

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

Assign static IP addresses to this Interface.

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. Calls update_host_maps() on the related Node in order to update any DHCP mappings.

Parameters:
  • 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 cluter 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.
  • update_host_maps – If True, will update any relevant DHCP mappings in addition to allocating the address.
Returns:

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.

Raises:

StaticIPAddressExhaustion if there are not enough IPs left.

Raises:

StaticIPAddressTypeClash if an IP already exists with a different type.

Raises:

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

Raises:

StaticIPAddressUnavailable if the requested_address is already allocated.

Raises:

StaticIPAddressForbidden if the address occurs within an existing dynamic range within the specified fabric.

get_cluster_interface()

Returns the cluster interface for this Interface, or None if it is unspecified or cannot be found.

classmethod get_type()

Get the type of interface for this class.

Return None on Interface.

update_ip_addresses(cidr_list)

Update the IP addresses linked to this interface.

Parameters:cidr_list – A list of IP/network addresses using the CIDR format

e.g. [‘192.168.12.1/24’, ‘fe80::9e4e:36ff:fe3b:1c94/64’] to which the interface is connected.

class maasserver.models.LargeFile(*args, **kwargs)

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

Files that are stored in the large object storage.

Only unique files are stored in the database, as only one sha256 value can exist per file. This provides data deduplication on the file level.

Currently only used by BootResourceFile. This speeds up the import process by only saving unique files.

Variables:
  • sha256 – Calculated SHA256 value of content.
  • total_size – Final size of content. The data might currently be saving, so total_size could be larger than size. size should never be larger than total_size.
  • content – File data.
complete

content has been completely saved.

delete(*args, **kwargs)

Delete this object.

Important: You must remove your reference to this object or it will not delete. Object will only be deleted if no other objects are referencing this object.

progress

Precentage of content saved.

size

Size of content.

valid

All content has been written and stored SHA256 value is the same as the calculated SHA256 value stored in the database.

Note: Depending on the size of the file, this can take some time.

class maasserver.models.LicenseKey(*args, **kwargs)

Bases: maasserver.models.timestampedmodel.TimestampedModel

Available license key for osystem and distro_series combo.

Each LicenseKey matches to a operating system and release. Only one license key can exists per osystem/distro_series combination.

class maasserver.models.MACAddress(*args, **kwargs)

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.
claim_static_ips(alloc_type=0, requested_address=None, fabric=None, user=None, update_host_maps=True)

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

get_attached_clusters_with_static_ranges()

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

get_cluster_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.

get_cluster_interfaces()

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_networks()

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

set_static_ip(requested_address, user, fabric=None, update_host_maps=True)

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.

Updates DNS for the cluster related to this MAC.

class maasserver.models.Network(*args, **kwargs)

Bases: maasserver.models.cleansave.CleanSave, django.db.models.base.Model

Network(id, name, ip, netmask, default_gateway, dns_servers, vlan_tag, description)

clean_netmask()

Validator for vlan_tag.

clean_vlan_tag()

Validator for vlan_tag.

get_connected_nodes()

Return the QuerySet of the nodes connected to this network.

Return type:django.db.models.query.QuerySet
get_network()

Return self as IPNetwork.

Raises AddrFormatError:
 If the combination of self.ip and self.netmask is a malformed network address.
class maasserver.models.Node(*args, **kwargs)

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

A Node represents a physical machine used by the MAAS Server.

Variables:
  • system_id – The unique identifier for this Node. (e.g. ‘node-41eba45e-4cfa-11e1-a052-00225f89f211’).
  • hostname – This Node‘s hostname. Must conform to RFCs 952 and 1123.
  • installable – An optional flag to indicate if this node can be installed or not. Non-installable nodes are nodes for which MAAS only manages DHCP and DNS.
  • parent – An optional parent Node. This node will be deleted along with all its resources when the parent node gets deleted or released. This is only relevant for non-installable nodes.
  • status – This Node‘s status. See the vocabulary NODE_STATUS.
  • error_description – A human-readable description of why a node is marked broken. Only meaningful when the node is in the state ‘BROKEN’.
  • owner – This Node‘s owner if it’s in use, None otherwise.
  • bios_boot_method – The boot method used by the cluster to allow this node to boot. E.g. “pxe”.
  • boot_type – This Node‘s booting method. See the vocabulary NODE_BOOT.
  • osystem – This Node‘s booting operating system, if it’s blank then the default_osystem will be used.
  • distro_series – This Node‘s booting distro series, if it’s blank then the default_distro_series will be used.
  • power_type – The power type that determines how this node will be powered on. Its value must match a power driver template name.
  • nodegroup – The NodeGroup this Node belongs to.
  • tags – The list of Tag`s associated with this `Node.
  • objects – The NodeManager.
abort_commissioning(*args, **kwargs)

Power off a commissioning node and set its status to NEW.

Returns:a Deferred which contains the post-commit tasks that are required to run to stop the node. This is already registered as a post-commit hook; it should not be added a second time.
abort_deploying(*args, **kwargs)

Power off a deploying node and set its status to ALLOCATED.

Returns:a Deferred which contains the post-commit tasks that are required to run to stop the node. This is already registered as a post-commit hook; it should not be added a second time.
abort_disk_erasing(user)

Power off disk erasing node and set a failed status.

Returns:a Deferred which contains the post-commit tasks that are required to run to stop the node. This is already registered as a post-commit hook; it should not be added a second time.
abort_operation(user)

Abort the current operation. This currently only supports aborting Disk Erasing.

accept_enlistment(user)

Accept this node’s (anonymous) enlistment.

This call makes sense only on a node in New state, i.e. one that has been anonymously enlisted and is now waiting for a MAAS user to accept that enlistment as authentic. Calling it on a node that is in Ready or Commissioning state, however, is not an error – it probably just means that somebody else has beaten you to it.

Returns:This node if it has made the transition from New, or None if it was already in an accepted state.
acquire(user, token=None, agent_name=u'', storage_layout=None, storage_layout_params={})

Mark commissioned node as acquired by the given user and token.

add_mac_address(mac_address)

Add a new MAC address to this Node.

Returns the corresponding MACAddress object if mac_address represents a MACAddress already assigned to this node.

Returns a new MACAddress object assigned to this node if this address is not assigned to any node in the system.

Raises a ValidationError if mac_address corresponds to a MACAddress already assigned to a different node.

Parameters:mac_address (unicode) – The MAC address to be added.
Raises:django.core.exceptions.ValidationError
claim_static_ip_addresses(mac=None, alloc_type=0, requested_address=None, update_host_maps=True)

Assign static IPs to a node’s MAC. If no MAC is specified, defaults to its PXE MAC.

By default, assigns IP addresses of type AUTO. If a different type is desired (such as STICKY), the optional alloc_type parameter can be used to override it.

By default, any address inside the cluster’s static range can be used. If the optional requested_address parameter is specified, will attempt to obtain it.

Returns:A list of (ip-address, mac-address) tuples.
Raises:StaticIPAddressExhaustion if there are not enough IPs left.
Raises:StaticIPAddressUnavailable if the supplied

requested_address is already in use.

clean_pxe_mac()

Check that this Node’s PXE MAC (if present) belongs to this Node.

It’s possible, though very unlikely, that the PXE MAC we are seeing is already assigned to another Node. If this happens, we need to catch the failure as early as possible.

clean_status()

Check a node’s status transition against the node-status FSM.

deallocate_static_ip_addresses(*args, **kwargs)

Release the StaticIPAddress that is assigned to this node and remove the host mapping on the cluster.

This should only be done when the node is in an unused state. If ip is supplied, only deallocate the specified address.

deallocate_static_ip_addresses_later()

Schedule for deallocate_static_ip_addresses to be called later.

This prevents the running task from blocking waiting for this task to finish. This can cause blocking and thread starvation inside the reactor threadpool.

delete()

Delete this node.

delete_host_maps(for_ips)

Delete any host maps for IPs allocated to this node.

This should probably live on NodeGroup.

Parameters:for_ips (set) – The set of IP addresses to remove host maps for.
display_memory()

Return memory in GiB.

display_status()

Return status text as displayed to the user.

display_storage()

Return storage in gigabytes.

dynamic_ip_addresses()

Dynamic IP addresses allocated to this node.

end_deployment()

Mark a node as successfully deployed.

fqdn

Fully qualified domain name for this node.

If MAAS manages DNS for this node or if this node doesn’t have a domain name set, replace or add the domain name configured on the cluster controller. Otherwise simply return the node’s hostname.

get_bios_boot_method()

Return the boot method the node’s BIOS booted.

get_boot_disk()

Return the boot disk for this node.

get_boot_purpose()

Return a suitable “purpose” for this boot, e.g. “install”.

get_commissioning_time()

Return the commissioning time of this node (in seconds).

This is the maximum time the commissioning is allowed to take.

get_deployment_status()

Return a string repr of the deployment status of this node.

get_deployment_time()

Return the deployment time of this node (in seconds).

This is the maximum time the deployment is allowed to take.

get_distro_series()

Return the distro series to install that node.

get_effective_kernel_options()

Determine any special kernel parameters for this node.

Returns:(tag, kernel_options) tag is a Tag object or None. If None, the kernel_options came from the global setting. kernel_options, a string indicating extra kernel_options that should be used when booting this node. May be None if no tags match and no global setting has been configured.
get_effective_license_key()

Return effective license key.

This returns the license key that should be used during the installation of the operating system for this node. This method first checks to see if the node has a specific license key set, if not then the license key registry is checked, if neither exists for this node or the booting operating system and release combination then an empty string is returned. An empty string can mean two things, one the operating system does not require a license key, or the installation media already has the license key builtin.

get_effective_power_info()

Get information on how to control this node’s power.

Returns a (can-be-started, can-be-stopped, power-type, power-parameters) tuple, where can-be-started and can-be-stopped are hints, based on the power type and power parameters, whether it’s even worth trying to control this node’s power.

Put another way, if can-be-started is False, the node almost certainly cannot be started. If it’s True, then it may be possible to control this node’s power, but there are no guarantees. The same goes for can-be-stopped.

Returns:PowerInfo (a namedtuple)
get_effective_power_parameters()

Return effective power parameters, including any defaults.

get_effective_power_type()

Get power-type to use for this node.

If no power type has been set for the node, raise UnknownPowerType.

get_extra_macs()

Get the MACs other that the one the node PXE booted from.

get_interfaces()

Return QuerySet for all the interfaces of this node.

get_next_ifname(ifnames=None)

Scans the interfaces on this Node and returns the next free ifname in the format ‘ethX’, where X is zero or a positive integer.

get_osystem()

Return the operating system to install that node.

get_primary_mac()

Return the primary MACAddress for this node.

get_pxe_mac()

Get the MAC address this node is expected to PXE boot from.

Normally, this will be the MAC address last used in a pxeconfig() API request for the node, as recorded in the ‘pxe_mac’ property. However, if the node hasn’t PXE booted since the ‘pxe_mac’ property was added to the Node model, this will return the node’s first MAC address instead.

get_pxe_mac_vendor()

Return the vendor of the MAC address the node pxebooted from.

get_releasing_time()

Return the releasing time of this node (in seconds).

This is the maximum time that releasing is allowed to take.

get_static_ip_mappings()

Return node’s static addresses, and their MAC addresses.

Returns:A list of (IP, MAC) tuples, both in string form.
handle_monitor_expired(context)

Handle a monitor expired event.

ip_addresses()

IP addresses allocated to this node.

Return the current IP addresses for this Node, or the empty list if there are none.

If disable_ipv4 is set, any IPv4 addresses will be omitted.

mac_addresses_on_managed_interfaces()

Return MACAddresses for this node that have a managed cluster interface.

mark_broken(error_description)

Mark this node as ‘BROKEN’.

If the node is allocated, release it first.

mark_failed(error_description)

Mark this node as failed.

The actual ‘failed’ state depends on the current status of the node.

mark_fixed()

Mark a broken node as fixed and change its state to ‘READY’.

physicalblockdevice_set

Return QuerySet for all PhysicalBlockDevice assigned to node.

This is need as Django doesn’t add this attribute to the Node model, it only adds blockdevice_set.

release()

Mark allocated or reserved node as available again and power off.

release_or_erase()

Either release the node or erase the node then release it, depending on settings.

remove_mac_address(mac_address)

Remove a MAC address from this Node.

Parameters:mac_address (string) – The MAC address to be removed.
set_netboot(on=True)

Set netboot on or off.

set_random_hostname()

Set hostname from a shuffled list of candidate names.

See gen_candidate_names.

http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names

set_storage_layout(layout, params={}, allow_fallback=True)

Set storage layout for this node.

set_zone(zone)

Set this node’s zone

split_arch()

Return architecture and subarchitecture, as a tuple.

start(*args, **kwargs)

Request on given user’s behalf that the node be started up.

Parameters:
  • by_user (User) – Requesting user.
  • user_data (unicode) – Optional blob of user-data to be made available to the node through the metadata service. If not given, any previous user data is used.
Raises:
  • StaticIPAddressExhaustion – if there are not enough IP addresses left in the static range for this node to get all the addresses it needs.
  • PermissionDenied – If by_user does not have permission to start this node.
Returns:

a Deferred which contains the post-commit tasks that are required to run to start the node. This is already registed as a post-commit hook; it should not be added a second time. If it has not been possible to start the node because the power controller does not support it, None will be returned. The node must be powered on manually.

start_commissioning(*args, **kwargs)

Install OS and self-test a new node.

Returns:a Deferred which contains the post-commit tasks that are required to run to start and commission the node. This is already registered as a post-commit hook; it should not be added a second time.
start_deployment()

Mark a node as being deployed.

start_disk_erasing(user)

Erase the disks on a node.

Returns:a Deferred which contains the post-commit tasks that are required to run to start and erase the node. This is already registered as a post-commit hook; it should not be added a second time.
start_transition_monitor(*args, **kwargs)

Start cluster-side transition monitor.

static_ip_addresses()

Static IP addresses allocated to this node.

stop(*args, **kwargs)

Request that the node be powered down.

Parameters:
  • by_user (User) – Requesting user.
  • stop_mode (unicode) – Power off mode - usually ‘soft’ or ‘hard’.
Raises PermissionDenied:
 

If by_user does not have permission to stop this node.

Returns:

a Deferred which contains the post-commit tasks that are required to run to stop the node. This is already registed as a post-commit hook; it should not be added a second time. If it has not been possible to stop the node because the power controller does not support it, None will be returned. The node must be powered off manually.

stop_transition_monitor(*args, **kwargs)

Stop cluster-side transition monitor.

storage

Return storage in megabytes.

Compatility with API 1.0 this field needs to exist on the Node.

update_host_maps(claims, nodegroups=None)

Update host maps for the given MAC->IP mappings.

If a nodegroup list is given, update all of them. If not, only update the nodegroup of the node.

static update_nodegroup_host_maps(nodegroups, claims)

Update host maps for the given MAC->IP mappings.

If a nodegroup list is given, update all of them. If not, only update the nodegroup of the node.

update_power_state(power_state)

Update a node’s power state

virtualblockdevice_set

Return QuerySet for all VirtualBlockDevice assigned to node.

This is need as Django doesn’t add this attribute to the Node model, it only adds blockdevice_set.

work_queue

The name of the queue for tasks specific to this node.

class maasserver.models.NodeGroup(*args, **kwargs)

Bases: maasserver.models.timestampedmodel.TimestampedModel

NodeGroup(id, created, updated, cluster_name, name, status, api_token_id, api_key, dhcp_key, uuid, maas_url, default_disable_ipv4)

accept()

Accept this nodegroup’s enlistment.

add_seamicro15k(user, mac, username, password, power_control=None, accept_all=False)

Add all of the specified cards the Seamicro SM15000 chassis at the specified MAC.

Parameters:
  • user – user for the nodes.
  • mac – MAC address of the card.
  • username – username for power controller.
  • password – password for power controller.
  • power_control – optional specify the power control method, either ipmi (default), restapi, or restapi2.
  • accept_all – commission enlisted nodes.
Raises NoConnectionsAvailable:
 

If no connections to the cluster are available.

add_virsh(user, poweraddr, password=None, prefix_filter=None, accept_all=False)

Add all of the virtual machines inside a virsh controller.

Parameters:
  • user – user for the nodes.
  • poweraddr – virsh connection string.
  • password – ssh password.
  • prefix_filter – imports virsh domains filtered by this prefix.
  • accept_all – commission enlisted nodes.
Raises NoConnectionsAvailable:
 

If no connections to the cluster are available.

add_vmware(user, host, username, password, protocol=None, port=None, prefix_filter=None, accept_all=False)

Add virtual machines managed by vSphere, ESX, or ESXi, or other VMware products which support the VMware API.

Parameters:
  • user – MAAS user (for commissioning)
  • host – VMware hostname.
  • username – VMware API username.
  • password – VMware API password.
  • prefix_filter – imports VMs with names filtered by this prefix.
  • accept_all – commission enlisted nodes.
Raises NoConnectionsAvailable:
 

If no connections to the cluster are available.

api_credentials

Return a string containing credentials for this nodegroup.

enlist_nodes_from_mscm(user, host, username, password, accept_all=False)

Add the servers from a Moonshot HP iLO Chassis Manager.

Parameters:
  • user – user for the nodes.
  • host – IP address for the MSCM.
  • username – username for MSCM.
  • password – password for MSCM.
  • accept_all – commission enlisted nodes.
Raises NoConnectionsAvailable:
 

If no connections to the cluster are available.

enlist_nodes_from_msftocs(user, ip, port, username, password, accept_all=False)

Add the servers from a Microsoft OCS Chassis Manager.

Parameters:
  • user – MAAS user for the nodes.
  • ip – IP address for the MicrosoftOCS.
  • port – Port for the MicrosoftOCS.
  • username – username for MicrosoftOCS.
  • password – password for MicrosoftOCS.
  • accept_all – commission enlisted nodes.
Raises NoConnectionsAvailable:
 

If no connections to the cluster are available.

enlist_nodes_from_ucsm(user, url, username, password, accept_all=False)

Add the servers from a Cicso UCS Manager.

Parameters:
  • user – user for the nodes.
  • URL – URL of the Cisco UCS Manager HTTP-XML API.
  • username – username for UCS Manager.
  • password – password for UCS Manager.
  • accept_all – commission enlisted nodes.
Raises NoConnectionsAvailable:
 

If no connections to the cluster are available.

ensure_dhcp_key()

Ensure that this nodegroup has a dhcp key.

This method persists the dhcp key without triggering the model signals (pre_save/post_save/etc) because it’s called from dhcp.configure_dhcp which, in turn, it called from the post_save signal of NodeGroup.

get_fabric()

The Fabric this cluster belongs to.

get_managed_interfaces()

Return the list of interfaces for which MAAS manages DHCP.

get_state()

Get the current state of the cluster.

This returns information about if the cluster is connected, out-of-sync, syncing, synced.

import_boot_images()

Import the pxe files on this cluster controller.

This will cause the cluster to connect to the region to download the images that are exposed there.

is_connected()

Is this cluster connected to his provisioning server?

manages_dhcp()

Does this NodeGroup manages a DHCP server?

This returns True when the NodeGroup is accepted, and has a NodeGroupInterface that’s set to manage DHCP.

manages_dns()

Does this NodeGroup manage DNS on any interfaces?

This returns True when the NodeGroup is accepted, and has a NodeGroupInterface that’s set to manage both DHCP and DNS.

reject()

Reject this nodegroup’s enlistment.

work_queue

The name of the queue for tasks specific to this nodegroup.

class maasserver.models.NodeGroupInterface(*args, **kwargs)

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

Cluster interface.

Represents a network to which a given cluster controller is connected. These interfaces are discovered automatically, but an admin can also add/edit/remove them.

This class duplicates some of Network, and adds settings for managing DHCP. Some day we hope to delegate the duplicated fields, and have auto-discovery populate the Network model along the way.

check_for_network_interface_clashes(exclude)

Validate uniqueness rules for network interfaces.

This enforces the rules that there can be only one IPv4 cluster interface on a given network interface on the cluster controller, and that there can be only one IPv6 cluster interface with a static range on a given network interface on the cluster controller. Aliases and VLANs count as separate network interfaces.

The IPv4 rule is inherent: a network interface (as seen in userspace) can only be on one IPv4 subnet. The IPv6 rule is needed because our current way of configuring IPv6 addresses on nodes, in /etc/network, does not support multiple addresses. So a network interface on a node can only be on one IPv6 subnet. Since the node’s network interface is connected to the same network segment as the cluster controller’s, that means that the cluster controller can only manage static IP addresses on one IPv6 subnet per network interface.

clean_ip_ranges()

Ensure that the static and dynamic ranges don’t overlap.

clean_network_valid()

Validate the network.

This validates that the network defined by ip and subnet_mask is valid.

clean_overlapping_networks()

Ensure that this interface’s network doesn’t overlap those of other interfaces on this cluster.

display_management()

Return management status text as displayed to the user.

is_managed

Return true if this interface is managed by MAAS.

manages_static_range()

Is this a managed interface with a static IP range configured?

network

Return the network defined by the interface’s address and netmask.

Returns:IPNetwork, or None if the netmask is unset.
Raises AddrFormatError:
 If the combination of interface address and subnet mask is malformed.
validate_unique(exclude=None)

Validate against conflicting NodeGroupInterface objects.

class maasserver.models.Partition(*args, **kwargs)

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

A partition in a partition table.

Variables:
  • partition_tablePartitionTable this partition belongs to.
  • uuid – UUID of the partition if it’s part of a GPT partition.
  • size – Size of the partition in bytes.
  • bootable – Whether the partition is set as bootable.
add_filesystem(uuid=None, fstype=None, label=None, create_params=None, mount_point=None, mount_params=None)

Creates a filesystem directly on this partition and returns it.

delete()

Delete the partition.

If this partition is part of a filesystem group then it cannot be deleted.

filesystem

Returns the filesystem that’s using this partition.

get_block_size()

Block size of partition.

get_name()

Return the name of the partition.

get_node()

Node this partition belongs to.

get_partition_number()

Return the partition number in the table.

remove_filesystem()

Deletes any filesystem on this partition. Do nothing if there is no filesystem on this partition.

save(*args, **kwargs)

Save partition.

type

Return the type.

class maasserver.models.PartitionTable(*args, **kwargs)

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

A partition table on a block device.

Variables:
  • table_type – Type of partition table.
  • block_deviceBlockDevice this partition table belongs to.
add_partition(size=None, bootable=False, uuid=None)

Adds a partition to this partition table, returns the added partition.

If size is omitted, the partition will extend to the end of the device.

If size is not a multiple of the device’s block size, the size will be rounded up to the next multiple.

get_available_size(ignore_partitions=[])

Return the remaining size available for partitions.

get_block_size()

Block size of partition table.

get_node()

Node this partition belongs to.

get_size()

Size of partition table.

class maasserver.models.PhysicalBlockDevice(*args, **kwargs)

Bases: maasserver.models.blockdevice.BlockDevice

A physical block device attached to a node.

class maasserver.models.PhysicalInterface(*args, **kwargs)

Bases: maasserver.models.interface.Interface

PhysicalInterface(id, created, updated, name, type, vlan_id, mac_id, ipv4_params, ipv6_params, params, tags)

class maasserver.models.RAID(*args, **kwargs)

Bases: maasserver.models.filesystemgroup.FilesystemGroup

A RAID.

add_device(device, fstype)

Adds a device to the array, creates the correct filesystem.

add_partition(partition, fstype)

Adds a partition to the array, creates the correct filesystem.

remove_device(device)

Removes the device from the RAID, removes the RAID filesystem.

Raises a ValidationError if the device is not part of the array or if the array becomes invalid with the deletion.

remove_partition(partition)

Removes the partition from the RAID, removes the RAID filesystem.

Raises a ValidationError if the device is not part of the array or if the array becomes invalid with the deletion.

class maasserver.models.Space(*args, **kwargs)

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

A Space.

Variables:
  • name – The short-human-identifiable name for this space.
  • objects – An instance of the class SpaceManager.
is_default()

Is this the default space?

class maasserver.models.SSHKey(*args, **kwargs)

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

An SSHKey represents a user public SSH key.

Users will be able to access allocated nodes using any of their registered keys.

Variables:
  • user – The user which owns the key.
  • key – The SSH public key.
display_html()

Return a compact HTML representation of this key.

Returns:The HTML representation of this key.
Return type:unicode
class maasserver.models.SSLKey(*args, **kwargs)

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

An SSLKey represents a user SSL key.

Users will be able to access Windows winrm service with any of the registered keys.

Variables:
  • user – The user which owns the key.
  • key – The SSL key.
display_html()

Return a compact HTML representation of this key.

Returns:The HTML representation of this key.
Return type:unicode
class maasserver.models.Subnet(*args, **kwargs)

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

Subnet(id, created, updated, name, vlan_id, space_id, cidr, gateway_ip, dns_servers)

class maasserver.models.Tag(*args, **kwargs)

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

A Tag is a label applied to a Node.

Variables:
  • name – The short-human-identifiable name for this tag.
  • definition – The XPATH string identifying what nodes should match this tag.
  • comment – A long-form description for humans about what this tag is trying to accomplish.
  • kernel_opts – Optional kernel command-line parameters string to be used in the PXE config for nodes with this tags.
  • objects – The TagManager.
populate_nodes()

Find all nodes that match this tag, and update them.

class maasserver.models.UserProfile(*args, **kwargs)

Bases: maasserver.models.cleansave.CleanSave, django.db.models.base.Model

A User profile to store MAAS specific methods and fields.

Variables:user – The related User.
create_authorisation_token()

Create a new Token and its related Consumer (OAuth authorisation).

Returns:A tuple containing the Consumer and the Token that were created.
Return type:tuple
delete_authorisation_token(token_key)

Delete the user’s OAuth token wich key token_key.

Parameters:token_key (string) – The key of the token to be deleted.
Raises:django.http.Http404
get_authorisation_tokens()

Fetches all the user’s OAuth tokens.

Returns:A QuerySet of the tokens.
Return type:django.db.models.query.QuerySet
class maasserver.models.VirtualBlockDevice(*args, **kwargs)

Bases: maasserver.models.blockdevice.BlockDevice

A virtual block device attached to a node.

get_name()

Return the name.

class maasserver.models.VolumeGroup(*args, **kwargs)

Bases: maasserver.models.filesystemgroup.FilesystemGroup

A volume group.

create_logical_volume(name, size, uuid=None)

Create a logical volume in this volume group.

update_block_devices_and_partitions(block_devices, partitions)

Update the block devices and partitions that are in this volume group.

class maasserver.models.Zone(*args, **kwargs)

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

A Zone is an entity used to logically group nodes together.

Variables:
  • name – The short-human-identifiable name for this zone.
  • description – Free-form description for this zone.
  • objects – An instance of the class ZoneManager.
device_only_set

Returns the non-installable nodes in this zone

is_default()

Is this the default zone?

node_only_set

Returns just the installable nodes in this zone

MAAS logo

MAAS

Metal As A Service.



Related Topics

This Page