#NEWLINE# def set_admin_password( self , new_pass ) : #NEWLINE# #INDENT# "Set the root/admin password on the VM instance.\n\n        This is done via an agent running on the VM. Communication between nova\n        and the agent is done via writing xenstore records. Since communication\n        is done over the XenAPI RPC calls, we need to encrypt the password.\n        We're using a simple Diffie-Hellman class instead of a more advanced\n        library (such as M2Crypto) for compatibility with the agent code.\n        " #NEWLINE# LOG . debug ( 'Setting admin password' , instance = self . instance ) #NEWLINE# try : #NEWLINE# #INDENT# dh = self . _exchange_key_with_agent ( ) #NEWLINE# #UNINDENT# except exception . AgentError as error : #NEWLINE# #INDENT# self . _add_instance_fault ( error , sys . exc_info ( ) ) #NEWLINE# return #NEWLINE# #UNINDENT# enc_pass = dh . encrypt ( ( new_pass + '\n' ) ) #NEWLINE# args = { #NEWLINE# #INDENT# 'enc_pass' : enc_pass , #NEWLINE# #UNINDENT# } #NEWLINE# self . _call_agent ( 'password' , args ) #NEWLINE# self . _save_instance_password_if_sshkey_present ( new_pass )