Comment 4 for bug 1293791

Revision history for this message
Raphaƫl Badin (rvb) wrote :

I might be missing something, but I think Scott is right.

Here is get_effective_power_parameters() from node.py:

    def get_effective_power_parameters(self):
        """Return effective power parameters, including any defaults."""
        [...]
        # The "mac" parameter defaults to the node's primary MAC
        # address, but only if not already set.
        if 'mac_address' not in power_params:
            primary_mac = self.get_primary_mac()
            if primary_mac is not None:
                mac = primary_mac.mac_address.get_raw()
                power_params['mac_address'] = mac
        return power_params

We can see that the primary MAC (i.e. the first MAC from the *host*) is put in the power_params if it doesn't already contain a value for the key 'mac_address'.

Later on, in src/provisioningserver/tasks.py, we use this MAC address to find the corresponding IP using ARP:

def issue_power_action(power_type, power_change, **kwargs):
    """Issue a power action to a node.

    :param power_type: The node's power type. Must have a corresponding
        power template.
    :param power_change: The change to request: 'on' or 'off'.
    :param **kwargs: Keyword arguments are passed on to :class:`PowerAction`.
    """
    assert power_change in ('on', 'off'), (
        "Unknown power change keyword: %s" % power_change)
    kwargs['power_change'] = power_change
    if 'mac_address' in kwargs:
        kwargs['ip_address'] = find_ip_via_arp(kwargs['mac_address'])
    [...]