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

BootImage(*args, **kwargs) Available boot image (i.e.
BootSource(*args, **kwargs) A source for boot resources.
BootSourceSelection(*args, **kwargs) A set of selections for a single BootSource.
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.
DownloadProgress(*args, **kwargs) Progress report from a cluster for one of its boot-image downloads.
FileStorage(*args, **kwargs) A simple file storage keyed on file name.
HandlerDocumentation(handler)
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, 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)
NodeGroupInterface(*args, **kwargs) NodeGroupInterface(id, created, updated, ip, nodegroup_id, management, interface, subnet_mask, broadcast_ip, router_ip, ip_range_low, ip_range_high, static_ip_range_low, static_ip_range_high, foreign_dhcp_ip)
SSHKey(*args, **kwargs) An SSHKey represents a user public SSH key.
SSLKey(*args, **kwargs) An SSLKey represents a user SSL key.
StaticIPAddress(*args, **kwargs) StaticIPAddress(id, created, updated, ip, alloc_type, user_id)
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.
Zone(*args, **kwargs) A Zone is an entity used to logically group nodes together.
class maasserver.models.BootImage(*args, **kwargs)

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

Available boot image (i.e. kernel and initrd).

Each BootImage represents a type of boot for which a boot image is available. The maas-import-pxe-files script imports these, and the TFTP server provides them to booting nodes.

If a boot image is missing, that may mean that the import script has not been run yet, or has failed; or that it was not configured to provide that particular image.

Fields correspond directly to values used in the tftppath module.

clean_xinstall()

Validates that xinstall_path and xinstall_type are valid when xinstall purpose is set.

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

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

A source for boot resources.

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.

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.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.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.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.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_ip(alloc_type=0)

Assign a static IP to this MAC.

It is the caller’s responsibility to create a celery Task that will write the dhcp host. It is not done here because celery doesn’t guarantee job ordering, and if the host entry is written after the host boots it is too late.

Parameters:alloc_type – See StaticIPAddress.alloc_type. This parameter musn’t be IPADDRESS_TYPE.USER_RESERVED.
Returns:A StaticIPAddress object. Returns None 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 already exists for this type, it is always returned with no further allocation.
Raises:StaticIPAddressExhaustion if there are not enough IPs left.
Raises:StaticIPAddressTypeClash if an IP already exists with a different type.
get_networks()

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

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

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

Network(id, name, ip, netmask, 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.
  • status – This Node‘s status. See the vocabulary NODE_STATUS.
  • owner – This Node‘s owner if it’s in use, None otherwise.
  • 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(user)

Power off a commissioning node and set its status to ‘declared’.

accept_enlistment(user)

Accept this node’s (anonymous) enlistment.

This call makes sense only on a node in Declared 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 Declared, or None if it was already in an accepted state.
acquire(user, token=None, agent_name=u'')

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

add_mac_address(mac_address)

Add a new MAC address to this Node.

Parameters:mac_address (unicode) – The MAC address to be added.
Raises:django.core.exceptions.ValidationError
claim_static_ips()

Assign AUTO static IPs for our MACs and return a list of Celery tasks that need executing. If nothing needs executing, the empty list is returned.

Each MAC on the node that is connected to a managed cluster interface will get an IP.

This operation is atomic; if claiming an IP on a particular MAC fails then none of the MACs will get an IP and StaticIPAddressExhaustion is raised.

clean_status()

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

delete_static_host_maps(for_ips)

Delete any host maps for static IPs allocated to this node.

Parameters:for_ips – Delete the maps for these IP addresses only.
display_status()

Return status text as displayed to the user.

The UI representation is taken from NODE_STATUS_CHOICES_DICT and may interpolate the variable “owner” to reflect the username of the node’s current owner, if any.

dynamic_ip_addresses()

Dynamic IP addresses allocated to this node.

fqdn

Fully qualified domain name for this node.

If MAAS manages DNS for this node, the domain part of the hostname (if present), is replaced by the domain configured on the cluster controller. If not, simply return the node’s hostname.

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_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_osystem()

Return the operating system to install that node.

get_primary_mac()

Return the primary MACAddress for this node.

ip_addresses()

IP addresses allocated to this node.

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

mac_addresses_on_managed_interfaces()

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

release()

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

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 5 character hostname using non-ambiguous characters.

Using 5 letters from the set ‘abcdefghjkmnpqrtwxy346789’ we get 9,765,625 combinations (pow(25, 5)).

Note that having a hostname starting with a number is perfectly valid, see http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names

should_use_fastpath_installer()

Should this node be installed with the Fast Path installer?

By default, nodes should be installed with the traditional installer, so this returns True when the use-fastpath-installer has been defined and False when it hasn’t.

should_use_traditional_installer()

Should this node be installed with the traditional installer?

By default, nodes should be installed with the traditional installer, so this returns True when no use-fastpath-installer tag has been defined.

split_arch()

Return architecture and subarchitecture, as a tuple.

start_commissioning(user)

Install OS and self-test a new node.

static_ip_addresses()

Static IP addresses allocated to this node.

use_fastpath_installer()

Set this node to be installed with the Fast Path Installer.

By default, nodes should be installed with the Traditional Installer.

Raises:RuntimeError when the use-fastpath-installer tag is defined with an expression. The reason is that the tag evaluation machinery will eventually ignore whatever changes you make with this method.
use_traditional_installer()

Set this node to be installed with the traditional installer.

By default, nodes should be installed with the Traditional installer.

Raises:RuntimeError when the use-traditional-installer tag is defined with an expression. The reason is that the tag evaluation machinery will eventually ignore whatever changes you make with this method.
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)

accept()

Accept this nodegroup’s enlistment.

add_seamicro15k(mac, username, password, power_control=None)

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

Parameters:
  • 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.
add_virsh(poweraddr, password=None)

Add all of the virtual machines inside a virsh controller.

Parameters:
  • poweraddr – virsh connection string
  • password – ssh password
enlist_nodes_from_mscm(host, username, password)

Add the servers from a Moonshot HP iLO Chassis Manager.

Parameters:
  • host – IP address for the MSCM.
  • username – username for MSCM.
  • password – password for MSCM.
enlist_nodes_from_ucsm(url, username, password)

Add the servers from a Cicso UCS Manager.

Parameters:
  • URL – URL of the Cisco UCS Manager HTTP-XML API.
  • username – username for UCS Manager.
  • password – password for UCS Manager.
ensure_boot_source_definition()

Set default boot source if none is currently defined.

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

Return the list of interfaces for which MAAS manages DHCP.

import_boot_images()

Import the pxe files on this cluster controller.

The files are downloaded through the proxy defined in the config setting ‘http_proxy’ if defined.

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

NodeGroupInterface(id, created, updated, ip, nodegroup_id, management, interface, subnet_mask, broadcast_ip, router_ip, ip_range_low, ip_range_high, static_ip_range_low, static_ip_range_high, foreign_dhcp_ip)

clean_ip_range_bounds()

Ensure that the static and dynamic ranges have sane bounds.

clean_ip_ranges()

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

clean_ips_in_network()

Ensure that the network settings are all congruent.

Specifically, it ensures that the router address, the DHCP address range, and the broadcast address if given, all fall within the network defined by the interface’s IP address and the subnet mask.

If no broadcast address is given, the network’s default broadcast address will be used.

clean_network_valid()

Validate the network.

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

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.
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.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.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.
is_default()

Is this the default zone?

MAAS logo

MAAS

Metal As A Service.



Related Topics

This Page