예제 #1
0
    def set_hostname(self, hostname=None):
        """
        Set this node's hostname to self.alias

        hostname - optional hostname to set (defaults to self.alias)
        """
        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
예제 #2
0
    def set_hostname(self, hostname=None):
        """
        Set this node's hostname to self.alias

        hostname - optional hostname to set (defaults to self.alias)
        """
        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