Beispiel #1
0
    def test_add_localnet_network(self, mock_db_set_command,
                                  mock_lsp_add_command, mock_ls_get_command,
                                  mock_ls_add_command, mock_connection):
        mock_ls_get_command.return_value.execute.return_value = (
            TestOvnNorth.NETWORK_LOCALNET_12)
        mock_ls_add_command.return_value.execute.return_value = (
            TestOvnNorth.NETWORK_LOCALNET_12)
        ovn_north = OvnNorth()
        rest_data = {
            NetworkMapper.REST_NETWORK_NAME: TestOvnNorth.NETWORK_NAME12,
            NetworkMapper.REST_PROVIDER_NETWORK_TYPE:
            NetworkMapper.NETWORK_TYPE_VLAN,
            NetworkMapper.REST_PROVIDER_PHYSICAL_NETWORK:
            TestOvnNorth.LOCALNET_NAME,
            NetworkMapper.REST_PROVIDER_SEGMENTATION_ID:
            TestOvnNorth.LOCALNET_VLAN
        }
        result = ovn_north.add_network(rest_data)

        self.assert_networks_equal(result, TestOvnNorth.NETWORK_LOCALNET_12)
        assert mock_ls_add_command.call_count == 1
        assert mock_ls_add_command.mock_calls[0] == mock.call(
            ovn_north.idl, TestOvnNorth.NETWORK_NAME12, False)
        assert mock_lsp_add_command.call_count == 1
        assert mock_lsp_add_command.mock_calls[0] == mock.call(
            ovn_north.idl, str(TestOvnNorth.NETWORK_LOCALNET_12.uuid),
            ovnconst.LOCALNET_SWITCH_PORT_NAME, None, None, False)
        assert mock_db_set_command.call_count == 3
        assert mock_ls_get_command.call_count == 1
Beispiel #2
0
    def test_add_network(self, mock_add_command, mock_connection):
        mock_add_command.return_value.execute.return_value = (
            TestOvnNorth.NETWORK_10)
        ovn_north = OvnNorth()
        rest_data = {
            NetworkMapper.REST_NETWORK_NAME: TestOvnNorth.NETWORK_NAME10
        }
        result = ovn_north.add_network(rest_data)

        self.assert_networks_equal(result, TestOvnNorth.NETWORK_10)
        assert mock_add_command.call_count == 1
        assert mock_add_command.mock_calls[0] == mock.call(
            ovn_north.idl, TestOvnNorth.NETWORK_NAME10, False)