<s> from contextlib import contextmanager <EOL> from oslo_utils import importutils <EOL> from ironic . common import exception <EOL> from ironic . common . i18n import _ <EOL> from ironic . drivers . modules import deploy_utils <EOL> REQUIRED_PROPERTIES = { <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> } <EOL> COMMON_PROPERTIES = REQUIRED_PROPERTIES <EOL> imcsdk = importutils . try_import ( '<STR_LIT>' ) <EOL> def parse_driver_info ( node ) : <EOL> """<STR_LIT>""" <EOL> info = { } <EOL> for param in REQUIRED_PROPERTIES : <EOL> info [ param ] = node . driver_info . get ( param ) <EOL> error_msg = ( _ ( "<STR_LIT>" <EOL> "<STR_LIT>" ) % <EOL> node . driver ) <EOL> deploy_utils . check_for_missing_params ( info , error_msg ) <EOL> return info <EOL> def handle_login ( task , handle , info ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> handle . login ( info [ '<STR_LIT>' ] , <EOL> info [ '<STR_LIT>' ] , <EOL> info [ '<STR_LIT>' ] ) <EOL> except imcsdk . ImcException as e : <EOL> raise exception . CIMCException ( node = task . node . uuid , error = e ) <EOL> @ contextmanager <EOL> def cimc_handle ( task ) : <EOL> """<STR_LIT>""" <EOL> info = parse_driver_info ( task . node ) <EOL> handle = imcsdk . ImcHandle ( ) <EOL> handle_login ( task , handle , info ) <EOL> try : <EOL> yield handle <EOL> finally : <EOL> handle . logout ( ) </s>
