<s> """<STR_LIT>""" <EOL> from oslo_log import log as logging <EOL> from nova import exception <EOL> from nova . i18n import _ , _LW <EOL> from nova . keymgr import mock_key_mgr <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class SingleKeyManager ( mock_key_mgr . MockKeyManager ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> LOG . warning ( _LW ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> super ( SingleKeyManager , self ) . __init__ ( ) <EOL> self . key_id = '<STR_LIT>' <EOL> self . key = self . _generate_key ( key_length = <NUM_LIT> ) <EOL> self . keys [ self . key_id ] = self . key <EOL> def _generate_hex_key ( self , ** kwargs ) : <EOL> key_length = kwargs . get ( '<STR_LIT>' , <NUM_LIT> ) <EOL> return '<STR_LIT:0>' * ( key_length / <NUM_LIT:4> ) <EOL> def _generate_key_id ( self ) : <EOL> return self . key_id <EOL> def store_key ( self , ctxt , key , ** kwargs ) : <EOL> if key != self . key : <EOL> raise exception . KeyManagerError ( <EOL> reason = _ ( "<STR_LIT>" ) ) <EOL> return super ( SingleKeyManager , self ) . store_key ( ctxt , key , ** kwargs ) <EOL> def delete_key ( self , ctxt , key_id , ** kwargs ) : <EOL> if ctxt is None : <EOL> raise exception . Forbidden ( ) <EOL> if key_id != self . key_id : <EOL> raise exception . KeyManagerError ( <EOL> reason = _ ( "<STR_LIT>" ) ) <EOL> LOG . warning ( _LW ( "<STR_LIT>" ) , key_id ) </s>
