'Set this node\'s hostname to self.alias
hostname - optional hostname to set (defaults to self.alias)'

def set_hostname(self, hostname=None):

    hostname = (hostname or self.alias)
    hostname_file = self.ssh.remote_file('/etc/hostname', 'w')
    hostname_file.write(hostname)
    hostname_file.close()
    try:
        self.ssh.execute('hostname    -F    /etc/hostname')
    except:
        if (not utils.is_valid_hostname(hostname)):
            raise exception.InvalidHostname(('Please    terminate    and    recreate    this    cluster    with    a    name    that    is    also    a    valid    hostname.        This    hostname    is    invalid:    %s' % hostname))
        else:
            raise
