<s> from oslo_config import cfg <EOL> from nova import context as nova_context <EOL> from nova import test <EOL> from nova . tests . unit import fake_instance <EOL> from nova . tests . unit . virt . ironic import utils as ironic_utils <EOL> from nova . virt . ironic import patcher <EOL> CONF = cfg . CONF <EOL> class IronicDriverFieldsTestCase ( test . NoDBTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( IronicDriverFieldsTestCase , self ) . setUp ( ) <EOL> self . image_meta = ironic_utils . get_test_image_meta ( ) <EOL> self . flavor = ironic_utils . get_test_flavor ( ) <EOL> self . ctx = nova_context . get_admin_context ( ) <EOL> self . instance = fake_instance . fake_instance_obj ( self . ctx ) <EOL> self . node = ironic_utils . get_test_node ( driver = '<STR_LIT>' ) <EOL> self . _expected_deploy_patch = [ <EOL> { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : self . image_meta . id , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : str ( self . instance [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : str ( self . flavor [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : self . instance [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : str ( self . instance [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : str ( self . instance [ '<STR_LIT>' ] ) , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : str ( self . node . properties . get ( '<STR_LIT>' , <NUM_LIT:0> ) ) , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> ] <EOL> def test_create_generic ( self ) : <EOL> node = ironic_utils . get_test_node ( driver = '<STR_LIT>' ) <EOL> patcher_obj = patcher . create ( node ) <EOL> self . assertIsInstance ( patcher_obj , patcher . GenericDriverFields ) <EOL> def test_generic_get_deploy_patch ( self ) : <EOL> node = ironic_utils . get_test_node ( driver = '<STR_LIT>' ) <EOL> patch = patcher . create ( node ) . get_deploy_patch ( <EOL> self . instance , self . image_meta , self . flavor ) <EOL> self . assertEqual ( sorted ( self . _expected_deploy_patch ) , sorted ( patch ) ) <EOL> def test_generic_get_deploy_patch_capabilities ( self ) : <EOL> node = ironic_utils . get_test_node ( driver = '<STR_LIT>' ) <EOL> self . flavor [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> expected = [ { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ] <EOL> expected += self . _expected_deploy_patch <EOL> patch = patcher . create ( node ) . get_deploy_patch ( <EOL> self . instance , self . image_meta , self . flavor ) <EOL> self . assertEqual ( sorted ( expected ) , sorted ( patch ) ) <EOL> def test_generic_get_deploy_patch_capabilities_op ( self ) : <EOL> node = ironic_utils . get_test_node ( driver = '<STR_LIT>' ) <EOL> self . flavor [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> expected = [ { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ] <EOL> expected += self . _expected_deploy_patch <EOL> patch = patcher . create ( node ) . get_deploy_patch ( <EOL> self . instance , self . image_meta , self . flavor ) <EOL> self . assertEqual ( sorted ( expected ) , sorted ( patch ) ) <EOL> def test_generic_get_deploy_patch_capabilities_nested_key ( self ) : <EOL> node = ironic_utils . get_test_node ( driver = '<STR_LIT>' ) <EOL> self . flavor [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> expected = [ { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ] <EOL> expected += self . _expected_deploy_patch <EOL> patch = patcher . create ( node ) . get_deploy_patch ( <EOL> self . instance , self . image_meta , self . flavor ) <EOL> self . assertEqual ( sorted ( expected ) , sorted ( patch ) ) <EOL> def test_generic_get_deploy_patch_ephemeral ( self ) : <EOL> CONF . set_override ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> node = ironic_utils . get_test_node ( driver = '<STR_LIT>' ) <EOL> instance = fake_instance . fake_instance_obj ( self . ctx , <EOL> ephemeral_gb = <NUM_LIT:10> ) <EOL> patch = patcher . create ( node ) . get_deploy_patch ( <EOL> instance , self . image_meta , self . flavor ) <EOL> expected = [ { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : str ( instance . ephemeral_gb ) , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ] <EOL> expected += self . _expected_deploy_patch <EOL> self . assertEqual ( sorted ( expected ) , sorted ( patch ) ) <EOL> def test_generic_get_deploy_patch_preserve_ephemeral ( self ) : <EOL> node = ironic_utils . get_test_node ( driver = '<STR_LIT>' ) <EOL> for preserve in [ True , False ] : <EOL> patch = patcher . create ( node ) . get_deploy_patch ( <EOL> self . instance , self . image_meta , self . flavor , <EOL> preserve_ephemeral = preserve ) <EOL> expected = [ { '<STR_LIT:path>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : str ( preserve ) , '<STR_LIT>' : '<STR_LIT>' , } ] <EOL> expected += self . _expected_deploy_patch <EOL> self . assertEqual ( sorted ( expected ) , sorted ( patch ) ) </s>
