#NEWLINE# def test_nexus_vlan_config_two_hosts( self ) : #NEWLINE# #INDENT# 'Verify config/unconfig of vlan on two compute hosts.' #NEWLINE# @ contextlib . contextmanager #NEWLINE# def _create_port_check_vlan( comp_host_name , device_id , which_interface , which_vlan , vlan_creation_expected = True ) : #NEWLINE# #INDENT# with self . port ( subnet = subnet , fmt = self . fmt ) as port : #NEWLINE# #INDENT# data = { #NEWLINE# #INDENT# 'port' : { #NEWLINE# #INDENT# portbindings . HOST_ID : comp_host_name , #NEWLINE# 'device_id' : device_id , #NEWLINE# 'device_owner' : DEVICE_OWNER , #NEWLINE# 'admin_state_up' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# req = self . new_update_request ( 'ports' , data , port [ 'port' ] [ 'id' ] ) #NEWLINE# req . get_response ( self . api ) #NEWLINE# self . assertTrue ( self . _is_vlan_configured ( which_interface , which_vlan , vlan_creation_expected = vlan_creation_expected ) ) #NEWLINE# self . mock_ncclient . reset_mock ( ) #NEWLINE# ( yield ) #NEWLINE# #UNINDENT# self . _delete ( 'ports' , port [ 'port' ] [ 'id' ] ) #NEWLINE# #UNINDENT# with self . _mock_config_trunk ( allowed_vlan_cfg_present = False ) : #NEWLINE# #INDENT# with self . network ( name = NETWORK_NAME ) as network : #NEWLINE# #INDENT# with self . subnet ( network = subnet , cidr = CIDR_1 ) as subnet : #NEWLINE# #INDENT# self . assertTrue ( self . _is_interface_initialized ( [ '1/1' , '1/2' ] ) ) #NEWLINE# with _create_port_check_vlan ( COMP_HOST_NAME , DEVICE_ID_1 , '1/1' , '1000' , vlan_creation_expected = True ) : #NEWLINE# #INDENT# with _create_port_check_vlan ( COMP_HOST_NAME_2 , DEVICE_ID_2 , '1/2' , '1000' , vlan_creation_expected = True ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# self . assertTrue ( self . _is_vlan_unconfigured ( vlan_deletion_expected = False ) ) #NEWLINE# self . mock_ncclient . reset_mock ( ) #NEWLINE# #UNINDENT# self . assertTrue ( self . _is_vlan_unconfigured ( vlan_deletion_expected = True ) )