#NEWLINE# def setupHostname( self , hostname ) : #NEWLINE# #INDENT# 'Handles the setup of a hostname for the node' #NEWLINE# if ( ( hnTmp . inMountNamespace is False ) or ( self . inUTSNamespace is False ) ) : #NEWLINE# #INDENT# raise Exception ( ( 'Hostname for node %s cannot be set\nNode must be in a mount and UTS namespaces\n' % self ) ) #NEWLINE# #UNINDENT# hnTmp = tempfile . NamedTemporaryFile ( prefix = ( 'mx-hostname-%s' % self ) , delete = False ) #NEWLINE# hnTmp . write ( hostname ) #NEWLINE# self . bindObject ( hnTmp . name , '/etc/hostname' ) #NEWLINE# hostsTmp = tempfile . NamedTemporaryFile ( prefix = ( 'mx-hosts-%s' % self ) , delete = False ) #NEWLINE# shutil . copyfile ( '/etc/hosts' , hostsTmp . name ) #NEWLINE# hostsTmp . seek ( 0 , 2 ) #NEWLINE# hostsTmp . write ( '\n# MiniNExT Container Hostname\n' ) #NEWLINE# hostsTmp . write ( ( '127.0.1.1\t%s\n\n' % self ) ) #NEWLINE# self . bindObject ( hostsTmp . name , '/etc/hosts' ) #NEWLINE# self . cmd ( ( 'hostname %s' % self . name ) )